This repository was archived by the owner on Sep 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathuiLayoutContainer.spec.js
94 lines (75 loc) · 3.39 KB
/
uiLayoutContainer.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
'use strict';
describe('Directive: uiLayoutContainer', function () {
var scope, element, $compile,
template = function(params) {
return '' +
'<div ui-layout="{flow: \'column\'}" ui-layout-loaded ' + (params.animate || '') + '>' +
' <div ui-layout-container collapsed="layout.beforeContainer" size="100px" min-size="50px" max-size="200px" resizable="false">One</div>' +
' <div ui-layout-container data-collapsed="layout.afterContainer">Two</div>' +
'</div>';
};
function createDirective(layout) {
var elm;
scope.layout = layout;
elm = angular.element(template(layout));
angular.element(document.body).prepend(elm);
$compile(elm)(scope);
scope.$digest();
return elm;
}
beforeEach(function () {
module('ui.layout');
inject(function ($rootScope, _$compile_) {
scope = $rootScope.$new();
$compile = _$compile_;
});
});
afterEach(function () {
if (element) element.remove();
});
it('should get initial attribute values', function () {
// this tests values _after_ the layout has been calculated
element = createDirective({ beforeContainer: true, afterContainer: false });
var divs = element.find('div'),
beforeContainer = divs[0],
afterContainer = divs[2],
bcScope = angular.element(beforeContainer).isolateScope(),
acScope = angular.element(afterContainer).isolateScope();
// you would expect true, but see explanation in uiLayoutLoaded
expect(bcScope.container.collapsed).toEqual(false);
expect(bcScope.container.resizable).toEqual(false);
expect(bcScope.container.size).toEqual(100);
expect(bcScope.container.uncollapsedSize).toEqual('100px');
expect(bcScope.container.minSize).toEqual(50);
expect(bcScope.container.maxSize).toEqual(200);
expect(acScope.container.collapsed).toEqual(false);
expect(acScope.container.resizable).toEqual(true);
// size has been be calculated, this is tested elsewhere
expect(acScope.container.minSize).toBeNull();
expect(acScope.container.maxSize).toBeNull();
});
it('should be animated when the attribute is explicitly set', function() {
element = createDirective({ beforeContainer: true, afterContainer: false, animate: 'animate="true"'});
var divs = element.find('div'),
beforeContainer = divs[0],
afterContainer = divs[2];
expect(angular.element(beforeContainer).hasClass('animate-column')).toEqual(true);
expect(angular.element(afterContainer).hasClass('animate-column')).toEqual(true);
});
it('should be animated when the attribute is not set', function() {
element = createDirective({ beforeContainer: true, afterContainer: false});
var divs = element.find('div'),
beforeContainer = divs[0],
afterContainer = divs[2];
expect(angular.element(beforeContainer).hasClass('animate-column')).toEqual(true);
expect(angular.element(afterContainer).hasClass('animate-column')).toEqual(true);
});
it('should not be animated when the attribute is set to false', function() {
element = createDirective({ beforeContainer: true, afterContainer: false, animate: 'animate="false"'});
var divs = element.find('div'),
beforeContainer = divs[0],
afterContainer = divs[2];
expect(angular.element(beforeContainer).hasClass('animate-column')).toEqual(false);
expect(angular.element(afterContainer).hasClass('animate-column')).toEqual(false);
});
});