Skip to content

Commit fd24d84

Browse files
creativedrewyrajexcited
authored andcommitted
Added a couple of unit tests around new countdown timer setting event.
1 parent e1893fa commit fd24d84

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/unit/timerSetTimeTest.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
describe('timer-set-countdown-seconds event handling tests', function () {
4+
beforeEach(module('timer'));
5+
6+
it('should call the event and set single digit seconds correctly', function () {
7+
inject(function ($compile, $rootScope, $timeout) {
8+
var scope = $rootScope.$new();
9+
var element = $compile('<timer countdown="10" interval="1000" autostart="false">{{sseconds}}</timer>')(scope);
10+
scope.$digest();
11+
12+
scope.$broadcast('timer-set-countdown-seconds', 5);
13+
14+
$timeout(function () {
15+
scope.$digest();
16+
expect(element.html().indexOf('05')).toBeGreaterThan(-1);
17+
}, 500);
18+
19+
$timeout.flush();
20+
});
21+
});
22+
23+
it('should call the event and set larger second values correctly', function () {
24+
inject(function ($compile, $rootScope, $timeout) {
25+
var scope = $rootScope.$new();
26+
var element = $compile('<timer countdown="10" interval="1000" autostart="false">{{mminutes}}:{{sseconds}}</timer>')(scope);
27+
scope.$digest();
28+
29+
scope.$broadcast('timer-set-countdown-seconds', 135);
30+
31+
$timeout(function () {
32+
scope.$digest();
33+
expect(element.html().indexOf('02:15')).toBeGreaterThan(-1);
34+
}, 500);
35+
36+
$timeout.flush();
37+
});
38+
});
39+
});

0 commit comments

Comments
 (0)