<commit_before>describe('Auth0-Widget', function () {

  var domain = 'mdocs.auth0.com';
  var widget = new Auth0Widget({
    domain:      domain,
    clientID:    '0HP71GSd6PuoRYJ3DXKdiXCUUdGmBbup', 
    callbackURL: 'http://localhost:3000/'
  });

  var client = widget.getClient();

  var removeWidget = function () {
    $('#auth0-widget').remove();
  };

  afterEach(function () {
    global.window.location.hash = '';
    removeWidget();
  });

  describe('Sign In', function () {
    it('should show notloggedin view if SSO data is not present', function (done) {
      client.getSSOData = function (callback) {
        callback(null, { sso: false });
      };

      widget.show(function () {
        expect($('#auth0-widget .notloggedin').css('display')).to.equal('block');
        expect($('#auth0-widget .loggedin').css('display')).to.equal('none');
        expect($('#auth0-widget .signup').css('display')).to.equal('none');
        expect($('#auth0-widget .reset').css('display')).to.equal('none');
        done();
      });
    });

    it('should show loggedin view with SSO data if it is present', function (done) {
      client.getSSOData = function (callback) {
        callback(null, { 
          sso: true, 
          lastUsedUsername: '<EMAIL>', 
          lastUsedConnection: { strategy: 'auth0', connection: 'contoso' }
        });
      };

      widget.show(function () {
        expect($('#auth0-widget .notloggedin').css('display')).to.equal('none');
        expect($('#auth0-widget .loggedin').css('display')).to.equal('block');
        expect($('#auth0-widget .signup').css('display')).to.equal('none');
        expect($('#auth0-widget .reset').css('display')).to.equal('none');
        expect($('#auth0-widget .loggedin .email input').val()).to.equal('<EMAIL>');
        done();
      });
    });
  });

  describe('Sign Up with auth0 connection', function () {
    // TODO
  });

  describe('Change Password with auth0 connection', function () {
    // TODO
  });

});<commit_msg>tests for login with social/db/enterprise connections<commit_after>describe('Auth0-Widget', function () {

  var domain =      'abc.auth0.com';
  var clientID =    '123456789';
  var callbackURL = 'http://myapp.com/callback';
  var widget, client;

  var removeWidget = function () {
    $('#auth0-widget').remove();
  };

  beforeEach(function () {
    widget = new Auth0Widget({
      domain:      domain,
      clientID:    clientID, 
      callbackURL: callbackURL
    });

    client = widget.getClient();
    client.getConnections = function (callback) {
      callback(null, [
        { name: 'google-oauth2', strategy: 'google-oauth2', status: true },
        { name: 'contoso', strategy: 'adfs', status: true, domain: 'contoso.com' },
        { name: 'dbTest', strategy: 'auth0', status: true, domain: '', showSignup: true, showForgot: true }
      ]);
    };
  });

  afterEach(function () {
    global.window.location.hash = '';
    removeWidget();
  });

  describe('Sign In', function () {
    it('should show only notloggedin view if SSO data is not present', function (done) {
      client.getSSOData = function (callback) {
        callback(null, { sso: false });
      };

      widget.show(function () {
        expect($('#auth0-widget .notloggedin').css('display')).to.equal('block');
        expect($('#auth0-widget .loggedin').css('display')).to.equal('none');
        expect($('#auth0-widget .signup').css('display')).to.equal('none');
        expect($('#auth0-widget .reset').css('display')).to.equal('none');
        done();
      });
    });

    it('should show only loggedin view with SSO data if it is present', function (done) {
      client.getSSOData = function (callback) {
        callback(null, { 
          sso: true, 
          lastUsedUsername: '<EMAIL>', 
          lastUsedConnection: { strategy: 'auth0', connection: 'dbTest' }
        });
      };

      widget.show(function () {
        expect($('#auth0-widget .notloggedin').css('display')).to.equal('none');
        expect($('#auth0-widget .loggedin').css('display')).to.equal('block');
        expect($('#auth0-widget .signup').css('display')).to.equal('none');
        expect($('#auth0-widget .reset').css('display')).to.equal('none');
        expect($('#auth0-widget .loggedin .email input').val()).to.equal('<EMAIL>');
        done();
      });
    });

    it('should signin with social connection', function (done) {
      client.getSSOData = function (callback) {
        callback(null, { sso: false });
      };

      client._redirect = function (the_url) {
        expect(the_url.split('?')[0]).to.contain('https://' + domain + '/authorize');
        done();
      };

      widget.show(function () {
        $('#auth0-widget .notloggedin .iconlist span[data-strategy="google-oauth2"]').trigger('click');
      });
    });

    it('should signin with database connection', function (done) {
      client.getSSOData = function (callback) {
        callback(null, { sso: false });
      };

      client.login = function (options) {
        expect(options.connection).to.equal('dbTest');
        expect(options.username).to.equal('<EMAIL>');
        expect(options.password).to.equal('<PASSWORD>');
        done();
      };

      widget.show(function () {
        $('#auth0-widget .notloggedin .emailPassword .email input').val('<EMAIL>');
        $('#auth0-widget .notloggedin .emailPassword .password input').val('<PASSWORD>');
        $('#auth0-widget .notloggedin .emailPassword .action button.primary').trigger('click');
      });
    });

    it('should signin with enterprise connection', function (done) {
      client.getSSOData = function (callback) {
        callback(null, { sso: false });
      };

      client._redirect = function (the_url) {
        expect(the_url.split('?')[0]).to.contain('https://' + domain + '/authorize');

        var parsed = {};
        the_url.split('?')[1].replace(
          new RegExp("([^?=&]+)(=([^&]*))?", "g"),
          function($0, $1, $2, $3) { parsed[$1] = decodeURIComponent($3); }
        );

        expect(parsed.connection).to.equal('contoso');
        done();
      };

      widget.show(function () {
        $('#auth0-widget .notloggedin .emailPassword .email input').val('<EMAIL>');
        $('#auth0-widget .notloggedin .emailPassword .action button.primary').trigger('click');
      });
    });
  });

  describe('Sign Up with auth0 connection', function () {
    // TODO
  });

  describe('Change Password with auth0 connection', function () {
    // TODO
  });

});
{'fraction_non_alphanumeric': 0.193858845096242, 'fraction_numerical': 0.010540788267644362, 'mean_word_length': 2.7997678467788742, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7268626', 'n_tokens_mistral': 2005, 'n_tokens_neox': 1971, 'n_words': 369}