<commit_before>"use strict";

describe("HeaderCtrl", function (){

    var scope, rootScope, _filter , _cache, _thisissoonAPI, _projects;

    beforeEach(function(){
        module("thisissoon.core");
    });

    beforeEach(inject(function ($rootScope, $injector, $controller) {

        scope = $rootScope.$new();
        rootScope = $rootScope;

        _filter = $injector.get("$filter");

        _cache = $injector.get("CacheService");

        _projects = {
            list: [
                { "id": 1, "background_colour": "#000000" },
                { "id": 2, "background_colour": "#000000" }
            ]
        };

        _thisissoonAPI = $injector.get("ThisissoonAPI");
        _thisissoonAPI.getProjects = function (){
            return {
                then: function(fn){ fn.call(this, _projects); }
            }
        }

        $controller("HeaderCtrl", {
            $scope: scope,
            $rootScope: rootScope,
            $filter: _filter,
            CacheService: _cache,
            ThisissoonAPI: _thisissoonAPI
        });

    }));

    it("should declare variables in scope", function (){
        expect(scope.env).toEqual(jasmine.any(Object));
        expect(scope.projects).toEqual(jasmine.any(Array));
        expect(scope.navStyle).toEqual(jasmine.any(String));
        expect(scope.toggleProjects).toEqual(jasmine.any(Function));
    });

    it("should toggle projectList boolean when calling toggleProjects function", function (){
        scope.cache.put("projectList", false);
        scope.toggleProjects();
        expect(scope.cache.get("projectList")).toBe(true);
        scope.toggleProjects();
        expect(scope.cache.get("projectList")).toBe(false);
        scope.cache.put("projectList", true);
        scope.toggleProjects();
        expect(scope.cache.get("projectList")).toBe(false);
    });

    it("should attach projects to scope on init", function (){
        scope.init();
        expect(scope.projects).toEqual(_projects.list);
    });

    it("should listen for scrollSectionChanged events from snNavbar and update scope", function (){
        scope.navStyle = "light";
        scope.$broadcast("snNavbar:scrollSectionChanged", { navStyle: "dark" })
        expect(scope.navStyle).toEqual("dark");
    });

});<commit_msg>add test for cache watch expression in HeaderCtrl<commit_after>"use strict";

describe("HeaderCtrl", function (){

    var scope, rootScope, _filter , _cache, _thisissoonAPI, _projects;

    beforeEach(function(){
        module("thisissoon.core");
    });

    beforeEach(inject(function ($rootScope, $injector, $controller) {

        scope = $rootScope.$new();
        rootScope = $rootScope;

        _filter = $injector.get("$filter");

        _cache = $injector.get("CacheService");

        _projects = {
            list: [
                { "id": 1, "background_colour": "#000000" },
                { "id": 2, "background_colour": "#000000" }
            ]
        };

        _thisissoonAPI = $injector.get("ThisissoonAPI");
        _thisissoonAPI.getProjects = function (){
            return {
                then: function(fn){ fn.call(this, _projects); }
            }
        }

        $controller("HeaderCtrl", {
            $scope: scope,
            $rootScope: rootScope,
            $filter: _filter,
            CacheService: _cache,
            ThisissoonAPI: _thisissoonAPI
        });

    }));

    it("should declare variables in scope", function (){
        expect(scope.env).toEqual(jasmine.any(Object));
        expect(scope.projects).toEqual(jasmine.any(Array));
        expect(scope.navStyle).toEqual(jasmine.any(String));
        expect(scope.toggleProjects).toEqual(jasmine.any(Function));
    });

    it("should toggle projectList boolean when calling toggleProjects function", function (){
        scope.cache.put("projectList", false);
        scope.toggleProjects();
        expect(scope.cache.get("projectList")).toBe(true);
        scope.toggleProjects();
        expect(scope.cache.get("projectList")).toBe(false);
        scope.cache.put("projectList", true);
        scope.toggleProjects();
        expect(scope.cache.get("projectList")).toBe(false);
    });

    it("should attach projects to scope on init", function (){
        scope.init();
        expect(scope.projects).toEqual(_projects.list);
    });

    it("should listen for scrollSectionChanged events from snNavbar and update scope", function (){
        scope.navStyle = "light";
        scope.$broadcast("snNavbar:scrollSectionChanged", { navStyle: "dark" })
        expect(scope.navStyle).toEqual("dark");
    });

    it("should watch project value in cache", function (){
        _cache.put("project", { backgroundColor: "#FFFFFF" });
        scope.$digest();

        expect(scope.navStyle).toEqual("dark");
    });

});
{'fraction_non_alphanumeric': 0.14758849099565308, 'fraction_numerical': 0.005795901469675016, 'mean_word_length': 2.5581737849779085, 'pattern_counts': {'":': 8, '<': 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': '3221928', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1333, 'n_words': 241}