<commit_before>describe('LoginController', function () {
	// this only tests the logic of the LoginController
	// if we want to test the logic of the LoginResource then
	// we will have to do that in a separate file
	beforeEach(module('EvalApp'));

	var $controller;

	var mockLoginResource = {
		login: function (user, pass) {
			return {
				success: function (fn) {
					if (user === 'snaebjorn13' && pass === '<PASSWORD>') {
						var response = {
							Token: 'ajfsjs<PASSWORD>',
							User: 'snaebjorn13'
						};
						fn(response);
					}
					return {
						error: function (errorFn) {
							if (user !== 'snaebjorn13' && pass === '<PASSWORD>') {
								errorFn();
							}
						}
					};
				}
			};
		}
	};

	beforeEach(inject(function (_$controller_) {
		$controller = _$controller_;
	}));

	describe('$scope.login', function () {
		var $scope, controller;

		beforeEach(function() {
			$scope = {};

			spyOn(mockLoginResource, 'login');
			spyOn(toastr, 'error');
			spyOn(toastr, 'success');

			controller = $controller('LoginController', 
				{ $scope:        $scope,
				  LoginResource: mockLoginResource });
		});

		it('should reject login when username is empty', function () {
			$scope.user = '';
			$scope.pass = '<PASSWORD>';
			$scope.login();
			expect(mockLoginResource.login).not.toHaveBeenCalled();
			expect(toastr.error).toHaveBeenCalled();<commit_msg>fikting in the spec<commit_after>describe('LoginController', function () {
	// this only tests the logic of the LoginController
	// if we want to test the logic of the LoginResource then
	// we will have to do that in a separate file
	beforeEach(module('EvalApp'));

	var $controller;

	/* var mockLoginResource = {
		login: function (user, pass) {
			return {
				success: function (fn) {
					if (user === 'snaebjorn13' && pass === '<PASSWORD>') {
						var response = {
							Token: 'aj<PASSWORD>',
							User: 'snaebjorn13'
						};
						fn(response);
					}
					return {
						error: function (errorFn) {
							if (user !== 'snaebjorn13' && pass === '<PASSWORD>') {
								errorFn();
							}
						}
					};
				}
			};
		}
	}; */

	var mockLoginResource = {
		user: '',
		pass: '',

		login: function (user, pass) {
			this.user = user;
			this.pass = pass;
			console.log(this.user + ' ' + this.pass);
			return this;
		},

		success: function (fn) {
			if (this.user === 'snaebjorn13' && this.pass === '<PASSWORD>') {
				var response = {
					Token: '<PASSWORD>',
					User: 'snaebjorn13'
				};
				fn(response);
				return this;
			}
		},

		error: function (errorFn) {
			if (this.user !== 'snaebjorn13' && this.pass !== '<PASSWORD>') {
				errorFn();
				return this;
			}
		}
	};

	beforeEach(inject(function (_$controller_) {
		$controller = _$controller_;
	}));

	describe('$scope.login', function () {
		var $scope, controller;

		beforeEach(function() {
			$scope = {};

			spyOn(mockLoginResource, 'login');
			spyOn(toastr, 'error');
			spyOn(toastr, 'success');

			controller = $controller('LoginController', 
				{ $scope:        $scope,
				  LoginResource: mockLoginResource });
		});

		it('should reject login when username is empty', function () {
			$scope.user = '';
			$scope.pass = '<PASSWORD>';
			$scope.login();
			expect(mockLoginResource.login).not.toHaveBeenCalled();
			expect(toastr.error).toHaveBeenCalled();
{'fraction_non_alphanumeric': 0.16377764494919306, 'fraction_numerical': 0.005379557680812911, 'mean_word_length': 2.887340301974448, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '639150', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1094, 'n_words': 252}