File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments