forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathionicActionSheet.unit.js
45 lines (34 loc) · 1.4 KB
/
ionicActionSheet.unit.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
describe('Ionic ActionSheet Service', function() {
var sheet, timeout, ionicPlatform;
beforeEach(module('ionic.service.actionSheet'));
beforeEach(module('ionic.service.platform'));
beforeEach(inject(function($ionicActionSheet, $timeout, $ionicPlatform) {
sheet = $ionicActionSheet;
timeout = $timeout;
ionicPlatform = $ionicPlatform;
}));
it('Should show', function() {
var s = sheet.show();
expect(s.el.classList.contains('active')).toBe(true);
});
it('Should add .action-sheet-up to .action-sheet-wrapper', function() {
var s = sheet.show();
var el = angular.element(s.el);
var wrapper = angular.element(s.el.querySelector('.action-sheet-wrapper'));
expect(wrapper.length).toEqual(1);
expect(wrapper.hasClass('action-sheet-up')).toEqual(false);
timeout.flush();
expect(wrapper.hasClass('action-sheet-up')).toEqual(true);
});
it('should handle hardware back button', function() {
var s = sheet.show();
ionicPlatform.hardwareBackButtonClick();
expect(s.el.classList.contains('active')).toBe(false);
});
it('show & hide should add action-sheet-open to body', inject(function($animate) {
var s = sheet.show();
expect(angular.element(document.body).hasClass('action-sheet-open')).toBe(true);
ionicPlatform.hardwareBackButtonClick();
expect(angular.element(document.body).hasClass('action-sheet-open')).toBe(false);
}));
});