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
/
fabToolbar.spec.js
72 lines (54 loc) · 2.09 KB
/
fabToolbar.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
describe('<md-fab-toolbar> directive', function() {
beforeEach(module('material.components.fabToolbar'));
var pageScope, element, controller;
function build(template) {
inject(function($compile, $rootScope) {
pageScope = $rootScope.$new();
element = $compile(template)(pageScope);
controller = element.controller('mdFabToolbar');
pageScope.$apply();
});
}
it('applies a class for each direction', inject(function() {
build(
'<md-fab-toolbar md-direction="{{direction}}"></md-fab-toolbar>'
);
pageScope.$apply('direction = "left"');
expect(element.hasClass('md-left')).toBe(true);
pageScope.$apply('direction = "right"');
expect(element.hasClass('md-right')).toBe(true);
}));
it('accepts a string for md-direction', inject(function() {
build(
'<md-fab-toolbar md-direction="right"></md-fab-toolbar>'
);
expect(element.hasClass('md-right')).toBe(true);
}));
it('allows programmatic opening through the md-open attribute', inject(function() {
build(
'<md-fab-toolbar md-open="isOpen"></md-fab-toolbar>'
);
// By default, it should be closed
expect(controller.isOpen).toBe(false);
// When md-open is true, it should be open
pageScope.$apply('isOpen = true');
expect(controller.isOpen).toBe(true);
// When md-open is false, it should be closed
pageScope.$apply('isOpen = false');
expect(controller.isOpen).toBe(false);
}));
it('properly finishes the animation', inject(function(mdFabToolbarAnimation) {
build(
'<md-fab-toolbar md-open="isOpen">' +
' <md-fab-trigger><button></button></md-fab-trigger>' +
' <md-fab-actions><md-toolbar><button></button></md-toolbar></md-fab-actions>' +
'</md-fab-toolbar>'
);
var addDone = jasmine.createSpy('addDone');
var removeDone = jasmine.createSpy('removeDone');
mdFabToolbarAnimation.addClass(element, 'md-is-open', addDone);
expect(addDone).toHaveBeenCalled();
mdFabToolbarAnimation.removeClass(element, 'md-is-open', removeDone);
expect(removeDone).toHaveBeenCalled();
}));
});