forked from siddii/angular-timer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request siddii#69 from creativedrewy/master
Added event handler so users can set countdown timer value dynamically.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
describe('timer-set-countdown-seconds event handling tests', function () { | ||
beforeEach(module('timer')); | ||
|
||
it('should call the event and set single digit seconds correctly', function () { | ||
inject(function ($compile, $rootScope, $timeout) { | ||
var scope = $rootScope.$new(); | ||
var element = $compile('<timer countdown="10" interval="1000" autostart="false">{{sseconds}}</timer>')(scope); | ||
scope.$digest(); | ||
|
||
scope.$broadcast('timer-set-countdown-seconds', 5); | ||
|
||
$timeout(function () { | ||
scope.$digest(); | ||
expect(element.html().indexOf('05')).toBeGreaterThan(-1); | ||
}, 500); | ||
|
||
$timeout.flush(); | ||
}); | ||
}); | ||
|
||
it('should call the event and set larger second values correctly', function () { | ||
inject(function ($compile, $rootScope, $timeout) { | ||
var scope = $rootScope.$new(); | ||
var element = $compile('<timer countdown="10" interval="1000" autostart="false">{{mminutes}}:{{sseconds}}</timer>')(scope); | ||
scope.$digest(); | ||
|
||
scope.$broadcast('timer-set-countdown-seconds', 135); | ||
|
||
$timeout(function () { | ||
scope.$digest(); | ||
expect(element.html().indexOf('02:15')).toBeGreaterThan(-1); | ||
}, 500); | ||
|
||
$timeout.flush(); | ||
}); | ||
}); | ||
}); |