-
Notifications
You must be signed in to change notification settings - Fork 297
/
Copy pathlayouts.spec.js
99 lines (78 loc) · 3.81 KB
/
layouts.spec.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'use strict';
describe('Controller: LayoutsDemoCtrl', function() {
var $scope, injections;
beforeEach(module('app'));
beforeEach(inject(function($rootScope, $controller, $window, $interval){
$scope = $rootScope.$new();
injections = {
$scope: $scope,
$interval: $interval
};
$controller('LayoutsDemoCtrl', injections);
}));
describe('the controller properties', function() {
it('should have properties in scope', function() {
expect($scope.randomValue).toBeDefined();
expect($scope.layoutOptions.storageId).toEqual('demo-layouts');
expect($scope.layoutOptions.storage).toBeDefined();
expect($scope.layoutOptions.storageHash).toEqual('fs4df4d51');
expect($scope.layoutOptions.widgetDefinitions).toBeDefined();
expect($scope.layoutOptions.defaultWidgets).toBeDefined();
expect($scope.layoutOptions.lockDefaultLayouts).toBe(true);
expect($scope.layoutOptions.defaultLayouts.length).toEqual(3);
expect($scope.layoutOptions.defaultLayouts[0].title).toEqual('Layout 1');
expect($scope.layoutOptions.defaultLayouts[0].active).toBe(true);
expect($scope.layoutOptions.defaultLayouts[0].defaultWidgets).toBeDefined();
expect($scope.layoutOptions.defaultLayouts[1].title).toEqual('Layout 2');
expect($scope.layoutOptions.defaultLayouts[1].active).toBe(false);
expect($scope.layoutOptions.defaultLayouts[1].defaultWidgets).toBeDefined();
expect($scope.layoutOptions.defaultLayouts[2].title).toEqual('Layout 3');
expect($scope.layoutOptions.defaultLayouts[2].active).toBe(false);
expect($scope.layoutOptions.defaultLayouts[2].defaultWidgets).toBeDefined();
expect($scope.layoutOptions.defaultLayouts[2].locked).toBe(false);
});
it('should change randomValue', function() {
var savedValue = $scope.randomValue;
injections.$interval.flush(500);
expect($scope.randomValue).not.toEqual(savedValue);
});
});
});
describe('Controller: LayoutsDemoExplicitSaveCtrl', function() {
var $scope, $interval;
beforeEach(module('app'));
beforeEach(inject(function($rootScope, $controller, _$interval_) {
$interval = _$interval_;
$scope = $rootScope.$new();
$controller('LayoutsDemoExplicitSaveCtrl', {
$scope: $scope,
$interval: $interval
});
}));
describe('the controller properties', function() {
it('should have properties in scope', function() {
expect($scope.randomValue).toBeDefined();
expect($scope.layoutOptions.storageId).toEqual('demo-layouts-explicit-save');
expect($scope.layoutOptions.storage).toBeDefined();
expect($scope.layoutOptions.storageHash).toEqual('fs4df4d51');
expect($scope.layoutOptions.widgetDefinitions).toBeDefined();
expect($scope.layoutOptions.defaultWidgets).toBeDefined();
expect($scope.layoutOptions.explicitSave).toBe(true);
expect($scope.layoutOptions.defaultLayouts.length).toEqual(3);
expect($scope.layoutOptions.defaultLayouts[0].title).toEqual('Layout 1');
expect($scope.layoutOptions.defaultLayouts[0].active).toBe(true);
expect($scope.layoutOptions.defaultLayouts[0].defaultWidgets).toBeDefined();
expect($scope.layoutOptions.defaultLayouts[1].title).toEqual('Layout 2');
expect($scope.layoutOptions.defaultLayouts[1].active).toBe(false);
expect($scope.layoutOptions.defaultLayouts[1].defaultWidgets).toBeDefined();
expect($scope.layoutOptions.defaultLayouts[2].title).toEqual('Layout 3');
expect($scope.layoutOptions.defaultLayouts[2].active).toBe(false);
expect($scope.layoutOptions.defaultLayouts[2].defaultWidgets).toBeDefined();
});
it('should change randomValue', function() {
var savedValue = $scope.randomValue;
$interval.flush(500);
expect($scope.randomValue).not.toEqual(savedValue);
});
});
});