forked from meanjs/mean
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.client.controller.tests.js
More file actions
61 lines (49 loc) · 1.71 KB
/
Copy pathheader.client.controller.tests.js
File metadata and controls
61 lines (49 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
(function () {
describe('HeaderController', function () {
// Initialize global variables
var scope,
HeaderController,
$state,
Authentication;
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
beforeEach(inject(function ($controller, $rootScope, _$state_, _Authentication_) {
scope = $rootScope.$new();
$state = _$state_;
Authentication = _Authentication_;
HeaderController = $controller('HeaderController as vm', {
$scope: scope
});
}));
it('should expose the authentication service', function () {
expect(scope.vm.authentication).toBe(Authentication);
});
it('should default menu to collapsed', function () {
expect(scope.vm.isCollapsed).toBeFalsy();
});
describe('when toggleCollapsibleMenu', function () {
var defaultCollapse;
beforeEach(function () {
defaultCollapse = scope.vm.isCollapsed;
scope.vm.isCollapsed = !scope.vm.isCollapsed;
});
it('should toggle isCollapsed to non default value', function () {
expect(scope.vm.isCollapsed).not.toBe(defaultCollapse);
});
it('should then toggle isCollapsed back to default value', function () {
scope.vm.isCollapsed = !scope.vm.isCollapsed;
expect(scope.vm.isCollapsed).toBe(defaultCollapse);
});
});
describe('when view state changes', function () {
beforeEach(function () {
scope.vm.isCollapsed = true;
scope.$broadcast('$stateChangeSuccess');
});
it('should set isCollapsed to false', function () {
expect(scope.vm.isCollapsed).toBeFalsy();
});
});
});
}());