This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
fabActions.spec.js
69 lines (56 loc) · 2.14 KB
/
fabActions.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
describe('<md-fab-actions> directive', function() {
beforeEach(module('material.components.fabActions'));
var pageScope, element, controller;
function build(template) {
inject(function($compile, $rootScope) {
pageScope = $rootScope.$new();
element = $compile(template)(pageScope);
controller = element.controller('mdFabActions');
pageScope.$apply();
});
}
it('supports static children', inject(function() {
build(
'<md-fab-speed-dial>' +
' <md-fab-actions>' +
' <md-button>1</md-button>' +
' <md-button>2</md-button>' +
' <md-button>3</md-button>' +
' </md-fab-actions>' +
'</md-fab-speed-dial>'
);
expect(element.find("md-fab-actions").children().length).toBe(3);
expect(element.find("md-fab-actions").children()).toHaveClass('md-fab-action-item');
}));
it('applies tabindex of -1 to all action item buttons', inject(function() {
build(
'<md-fab-speed-dial>' +
' <md-fab-actions>' +
' <md-button>1</md-button>' +
' <md-button>2</md-button>' +
' <md-button>3</md-button>' +
' </md-fab-actions>' +
'</md-fab-speed-dial>'
);
expect(element.find("md-button").length).toBe(3);
angular.forEach(element.find("md-button"), function(button) {
expect(button.getAttribute('tabindex')).toEqual('-1');
});
}));
angular.forEach(['ng-repeat', 'data-ng-repeat', 'x-ng-repeat'], function(attr) {
it('supports actions created by ' + attr, inject(function() {
build(
'<md-fab-speed-dial ng-init="nums=[1,2,3]">' +
' <md-fab-actions>' +
' <div ' + attr + '="i in nums"><md-button>{{i}}</md-button></div>' +
' </md-fab-actions>' +
'</md-fab-speed-dial>'
);
expect(element.find("md-fab-actions").children().length).toBe(3);
expect(element.find("md-fab-actions").children()).toHaveClass('md-fab-action-item');
pageScope.$apply('nums=[1,2,3,4]');
expect(element.find("md-fab-actions").children().length).toBe(4);
expect(element.find("md-fab-actions").children()).toHaveClass('md-fab-action-item');
}));
});
});