<commit_before>describe('$auth provider', function() {

  beforeEach(module('satellizer'));

  beforeEach(inject(['$window', '$location', '$httpBackend', '$auth', function($window, $location, $httpBackend, $auth) {
    this.$auth = $auth;
    this.$window = $window;
    this.$location = $location;
    this.$httpBackend = $httpBackend;
  }]));

  it('should be able to call login', function() {
    var token = '<KEY>';
    var user = { email: '<EMAIL>', password: '<PASSWORD>' };

//    $httpBackend.expectPOST('/auth/login').respond({ token: token });
//
//    $auth.login(user);
//
//    $httpBackend.flush();

//    expect(angular.isFunction($auth.login)).toBe(true);
  });

  it('should be able to handle login errors',function() {
    var user = {
      email: '<EMAIL>',
      password: '<PASSWORD>'
    };
    var rejected = false;

    this.$httpBackend.expectPOST('/auth/login').respond(404);

    this.$auth.login(user).then(angular.noop, function() {
      rejected = true;
    });

    this.$httpBackend.flush();

    expect(rejected).toBe(true);
  });

  it('should be able to call signup', function() {
    var user = {
      email: '<EMAIL>',
      password: '<PASSWORD>'
    };

    this.$httpBackend.expectPOST('/auth/signup').respond(200);

    this.$auth.signup(user);

    this.$httpBackend.flush();

    expect(angular.isFunction(this.$auth.signup)).toBe(true);
    expect(this.$location.path()).toEqual('/login');
  });

  it('should log out a user', function() {
    this.$auth.logout();
    expect(this.$window.localStorage['satellizer_token']).toBeUndefined();
    expect(this.$location.path()).toEqual('/');
  });

});
<commit_msg>auth spec refactoring<commit_after>describe('$auth', function() {

  beforeEach(module('satellizer'));

  beforeEach(inject(['$window', '$location', '$httpBackend', '$auth', function($window, $location, $httpBackend, $auth) {
    this.$auth = $auth;
    this.$window = $window;
    this.$location = $location;
    this.$httpBackend = $httpBackend;
  }]));

  it('should be defined', function() {
    expect(this.$auth).toBeDefined();
  });

  describe('authenticate()', function() {

    it('should be defined', function() {
      expect(this.$auth.authenticate).toBeDefined();
    });

  });

  describe('logout()', function() {

    it('should log out a user', function() {
      this.$auth.logout();
      expect(this.$window.localStorage['satellizer_token']).toBeUndefined();
      expect(this.$location.path()).toEqual('/');
    });

  });

  describe('login()', function() {

    it('should be able to handle login errors',function() {
      var user = {
        email: '<EMAIL>',
        password: '<PASSWORD>'
      };
      var rejected = false;

      this.$httpBackend.expectPOST('/auth/login').respond(404);

      this.$auth.login(user).then(angular.noop, function() {
        rejected = true;
      });

      this.$httpBackend.flush();

      expect(rejected).toBe(true);
    });

    it('should be able to call login', function() {
      var token = '<KEY>';
      var user = { email: '<EMAIL>', password: '<PASSWORD>' };

//    $httpBackend.expectPOST('/auth/login').respond({ token: token });
//
//    $auth.login(user);
//
//    $httpBackend.flush();

//    expect(angular.isFunction($auth.login)).toBe(true);
    });

  });

  describe('signup()', function() {

    it('should be able to call signup', function() {
      var user = {
        email: '<EMAIL>',
        password: '<PASSWORD>'
      };

      this.$httpBackend.expectPOST('/auth/signup').respond(200);

      this.$auth.signup(user);

      this.$httpBackend.flush();

      expect(angular.isFunction(this.$auth.signup)).toBe(true);
      expect(this.$location.path()).toEqual('/login');
    });

  });

});

{'fraction_non_alphanumeric': 0.2050119968008531, 'fraction_numerical': 0.003199146894161557, 'mean_word_length': 3.220472440944882, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, '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': '3052312', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1161, 'n_words': 203}