<commit_before>'use strict';

/* jasmine specs for controllers go here */
/* global describe, beforeEach, it, inject, expect */
describe('controllers', function() {
    var $scope;

    beforeEach(module('monkeyFace.controllers'));

    describe('ActivityLinkCtrl', function() {
        beforeEach(inject(function($rootScope, $controller) {
            $scope = $rootScope.$new();
            $controller('ActivityLinkCtrl', {$scope: $scope, activityLinkTargetProvider: {
                get: function() {
                    return {
                        type: 'dummy'
                    };
                },
                set: function() {

                }
            }});
        }));


        it('should have activities', inject(function() {
            expect(typeof $scope.activities).toEqual('object');
            expect($scope.activities.length).toEqual(2);
        }));

        it('should have not submit when form empty', inject(function() {
            expect($scope.formSubmitted).toBe(false);

            $scope.submit();
            expect($scope.formSubmitted).toBe(false);

            $scope.form = {
                name: ''
            };
            $scope.submit();
            expect($scope.formSubmitted).toBe(false);
        }));

        it('should submit when form is not empty', inject(function() {
            $scope.form = {
                name: 'test'
            };
            $scope.submit();
            expect($scope.formSubmitted).toBe(true);
        }));
    });
<commit_msg>Fixing and completing ActivityLinkCtrl tests<commit_after>'use strict';

/* jasmine specs for controllers go here */
/* global describe, beforeEach, it, inject, expect, spyOn */
describe('controllers', function() {
    var $scope;

    beforeEach(module('monkeyFace.controllers'));

    describe('ActivityLinkCtrl', function() {
        var backendMock;
        var getActivitiesCallback;

        beforeEach(inject(function($rootScope, $controller) {
            $scope = $rootScope.$new();

            var activityLinkTargetMock = {
                get: function() {
                    return {
                        type: 'dummy'
                    };
                },
                set: function() {

                }
            };

            backendMock = {
                getActivities: function() {
                    return {
                        success: function(cb) {
                            getActivitiesCallback = cb;
                        }
                    };
                }
            };

            spyOn(backendMock, 'getActivities').andCallThrough();

            $controller('ActivityLinkCtrl', {
                $scope: $scope,
                activityLinkTargetProvider: activityLinkTargetMock,
                backend: backendMock
            });
        }));


        it('should initialise activities to an empty array', inject(function() {
            expect(typeof $scope.activities).toEqual('object');
            expect($scope.activities.length).toEqual(0);
        }));

        it('should request activities from the backend', inject(function() {
            expect(backendMock.getActivities).toHaveBeenCalled();
            expect(backendMock.getActivities.calls.length).toEqual(1);

            // Make sure it binds to success
            expect(getActivitiesCallback).toBeDefined();
            expect(typeof getActivitiesCallback).toBe('function');

            // Give a couple of activities and make sure it exposes it
            getActivitiesCallback(['activity1', 'activity2']);
            expect($scope.activities.length).toEqual(2);
        }));

        it('should have not submit when form empty', inject(function() {
            expect($scope.formSubmitted).toBe(false);

            $scope.submit();
            expect($scope.formSubmitted).toBe(false);

            $scope.form = {
                name: ''
            };
            $scope.submit();
            expect($scope.formSubmitted).toBe(false);
        }));

        it('should submit when form is not empty', inject(function() {
            $scope.form = {
                name: 'test'
            };
            $scope.submit();
            expect($scope.formSubmitted).toBe(true);
        }));
    });

{'fraction_non_alphanumeric': 0.1254388017786099, 'fraction_numerical': 0.001404165691551603, 'mean_word_length': 1.6350184956843403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1657257', 'n_tokens_mistral': 1052, 'n_tokens_neox': 997, 'n_words': 202}