<commit_before>'use strict';

describe("Register Controller", function () {

    beforeEach(module('smlBootstrap.services', 'smlBootstrap.controllers'));

    afterEach(inject(function (_$httpBackend_) {
        _$httpBackend_.verifyNoOutstandingExpectation();
        _$httpBackend_.verifyNoOutstandingRequest();
    }));

    var scope, $httpBackend, ctrl;

    beforeEach(inject(function (_$httpBackend_, $rootScope, $routeParams, $controller) {
        $httpBackend = _$httpBackend_;

        scope = $rootScope.$new();
        ctrl = $controller('RegisterController', {$scope: scope});

        scope.user = {
            password: '',
            repeatPassword: ''
        };

        scope.registerForm = {
            login: {
                $dirty: false
            },
            email: {
                $dirty: false
            },
            password: {
                $dirty: false
            },
            repeatPassword: {
                $dirty: false,
                $error: {
                    dontMatch: false
                }
            },
            $invalid: false,
            $valid: true
        };
    }));

    it('Should call register rest service when form is valid', function () {
        // Given
        $httpBackend.expectPOST('rest/users/register').respond('anything');

        // When
        scope.register();
        $httpBackend.flush();
    });

    it('Should not call register rest service when form is invalid', function () {
        // Given
        scope.registerForm.$valid = false;

        // When
        scope.register();

        // Then
        // verifyNoOutstandingRequest(); is checked after each test
    });

    it('Should set error flag when passwords don\'t match', function () {
        // Given
        expect(scope.registerForm.repeatPassword.$error.dontMatch).toBe(false);

        scope.user.password = "<PASSWORD>";
        scope.user.repeatPassword = "<PASSWORD>";

        // When
        scope.checkPassword();

        // Then
        expect(scope.registerForm.repeatPassword.$error.dontMatch).toBe(true);
    });

    it('Should not set error flag when passwords match', function () {
        // Given
        expect(scope.registerForm.repeatPassword.$error.dontMatch).toBe(false);

        scope.user.password = "<PASSWORD>";
        scope.user.repeatPassword = "<PASSWORD>";

        // When
        scope.checkPassword();

        // Then
        expect(scope.registerForm.repeatPassword.$error.dontMatch).toBe(false);
    });

});<commit_msg>Fixing tests after introducing repeatPassword directive<commit_after>'use strict';

describe("Register Controller", function () {

    beforeEach(module('smlBootstrap.services', 'smlBootstrap.controllers'));

    afterEach(inject(function (_$httpBackend_) {
        _$httpBackend_.verifyNoOutstandingExpectation();
        _$httpBackend_.verifyNoOutstandingRequest();
    }));

    var scope, $httpBackend, ctrl;

    beforeEach(inject(function (_$httpBackend_, $rootScope, $routeParams, $controller) {
        $httpBackend = _$httpBackend_;

        scope = $rootScope.$new();
        ctrl = $controller('RegisterController', {$scope: scope});

        scope.user = {
            password: '',
            repeatPassword: ''
        };

        scope.registerForm = {
            login: {
                $dirty: false
            },
            email: {
                $dirty: false
            },
            password: {
                $dirty: false
            },
            repeatPassword: {
                $dirty: false,
                $error: {
                    repeat: false
                }
            },
            $invalid: false,
            $valid: true
        };
    }));

    it('Should call register rest service when form is valid', function () {
        // Given
        $httpBackend.expectPOST('rest/users/register').respond('anything');

        // When
        scope.register();
        $httpBackend.flush();
    });

    it('Should not call register rest service when form is invalid', function () {
        // Given
        scope.registerForm.$valid = false;

        // When
        scope.register();

        // Then
        // verifyNoOutstandingRequest(); is checked after each test
    });

    it("should not call register rest service when passwords don't match", function() {
        //Given
        scope.registerForm.repeatPassword.$error.repeat = true;

        //When
        scope.register();

        //Then
        //no outstanding requests (checked after test)
    });

});
{'fraction_non_alphanumeric': 0.1251372118551043, 'fraction_numerical': 0.0, 'mean_word_length': 1.8210526315789475, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5323218', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1130, 'n_words': 244}