Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 689cbc5

Browse files
committed
test(optionalAnimations): added tests to check whether css animation classes are added correctly
1 parent 7409000 commit 689cbc5

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

test/uiLayoutContainer.spec.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33

44
describe('Directive: uiLayoutContainer', function () {
55
var scope, element, $compile,
6-
template = '' +
7-
'<div ui-layout="{flow: \'column\'}" ui-layout-loaded>' +
8-
' <div ui-layout-container collapsed="layout.beforeContainer" size="100px" min-size="50px" max-size="200px" resizable="false">One</div>' +
9-
' <div ui-layout-container data-collapsed="layout.afterContainer">Two</div>' +
10-
'</div>';
6+
template = function(params) {
7+
return '' +
8+
'<div ui-layout="{flow: \'column\'}" ui-layout-loaded ' + (params.animate || '') + '>' +
9+
' <div ui-layout-container collapsed="layout.beforeContainer" size="100px" min-size="50px" max-size="200px" resizable="false">One</div>' +
10+
' <div ui-layout-container data-collapsed="layout.afterContainer">Two</div>' +
11+
'</div>';
12+
};
1113

1214
function createDirective(layout) {
1315
var elm;
1416

1517
scope.layout = layout;
16-
elm = angular.element(template);
18+
elm = angular.element(template(layout));
1719
angular.element(document.body).prepend(elm);
1820
$compile(elm)(scope);
1921
scope.$digest();
@@ -38,7 +40,7 @@ describe('Directive: uiLayoutContainer', function () {
3840

3941
it('should get initial attribute values', function () {
4042
// this tests values _after_ the layout has been calculated
41-
element = createDirective({ beforeContainer: true, afterContainer: false});
43+
element = createDirective({ beforeContainer: true, afterContainer: false });
4244
var divs = element.find('div'),
4345
beforeContainer = divs[0],
4446
afterContainer = divs[2],
@@ -61,4 +63,32 @@ describe('Directive: uiLayoutContainer', function () {
6163

6264
});
6365

66+
it('should be animated when the attribute is explicitly set', function() {
67+
element = createDirective({ beforeContainer: true, afterContainer: false, animate: 'animate="true"'});
68+
var divs = element.find('div'),
69+
beforeContainer = divs[0],
70+
afterContainer = divs[2];
71+
72+
expect(angular.element(beforeContainer).hasClass('animate-column')).toEqual(true);
73+
expect(angular.element(afterContainer).hasClass('animate-column')).toEqual(true);
74+
});
75+
76+
it('should not be animated when the attribute is not set', function() {
77+
element = createDirective({ beforeContainer: true, afterContainer: false});
78+
var divs = element.find('div'),
79+
beforeContainer = divs[0],
80+
afterContainer = divs[2];
81+
expect(angular.element(beforeContainer).hasClass('animate-column')).toEqual(false);
82+
expect(angular.element(afterContainer).hasClass('animate-column')).toEqual(false);
83+
});
84+
85+
it('should not be animated when the attribute is set to a value different from true', function() {
86+
element = createDirective({ beforeContainer: true, afterContainer: false, animate: 'animate="false"'});
87+
var divs = element.find('div'),
88+
beforeContainer = divs[0],
89+
afterContainer = divs[2];
90+
expect(angular.element(beforeContainer).hasClass('animate-column')).toEqual(false);
91+
expect(angular.element(afterContainer).hasClass('animate-column')).toEqual(false);
92+
});
93+
6494
});

0 commit comments

Comments
 (0)