Sha256: 17df6150d4d88a5de05c3cc7b10f7f005c809b8369b901c4df6d1316d40c99c9

Contents?: true

Size: 1.34 KB

Versions: 70

Compression:

Stored size: 1.34 KB

Contents

describe('Directive: setTitle', function () {
    var $scope, $compile, PageTitle, resource, element;

    beforeEach(module('Bastion.components', 'Bastion.test-mocks'));

    beforeEach(module(function ($provide) {
       PageTitle = {
           setTitle: function () {}
       };

       $provide.value('PageTitle', PageTitle);
    }));

    beforeEach(inject(function (_$compile_, _$rootScope_, MockResource) {
        $compile = _$compile_;
        $scope = _$rootScope_;
        resource = MockResource.$new().get({id: 1});
    }));

    it("should wait on a promise if the model is provided", function () {
        spyOn(PageTitle, 'setTitle');
        $scope.resource = resource;
        element = angular.element('<div page-title ng-model="resource">new awesome title</div>');

        $compile(element)($scope);
        expect(PageTitle.setTitle).not.toHaveBeenCalled();

        $scope.$digest();

        expect(PageTitle.setTitle).toHaveBeenCalledWith('new awesome title', jasmine.any(Object));
    });

    it("should set the page title without waiting for a $promise if none exists", function () {
        spyOn(PageTitle, 'setTitle');
        element = angular.element('<div page-title>new awesome title</div>');

        $compile(element)($scope);

        expect(PageTitle.setTitle).toHaveBeenCalledWith('new awesome title', jasmine.any(Object));
    });
});

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
bastion-6.1.23 test/components/page-title.directive.test.js
bastion-6.1.22 test/components/page-title.directive.test.js
bastion-6.1.21 test/components/page-title.directive.test.js
bastion-6.1.20 test/components/page-title.directive.test.js
bastion-6.1.19 test/components/page-title.directive.test.js
bastion-6.1.18 test/components/page-title.directive.test.js
bastion-6.1.17 test/components/page-title.directive.test.js
bastion-6.1.16 test/components/page-title.directive.test.js
bastion-6.1.15 test/components/page-title.directive.test.js
bastion-6.1.14 test/components/page-title.directive.test.js
bastion-6.1.13 test/components/page-title.directive.test.js
bastion-6.1.12 test/components/page-title.directive.test.js
bastion-6.1.11 test/components/page-title.directive.test.js
bastion-6.1.10 test/components/page-title.directive.test.js
bastion-6.1.9 test/components/page-title.directive.test.js
bastion-6.1.8 test/components/page-title.directive.test.js
bastion-6.1.7 test/components/page-title.directive.test.js
bastion-6.1.6 test/components/page-title.directive.test.js
bastion-6.1.5 test/components/page-title.directive.test.js
bastion-6.1.4 test/components/page-title.directive.test.js