@@ -19,18 +19,17 @@ class Counter extends Component {
1919 }
2020}
2121
22+ const WrappedCounter = timer ( 1000 ) ( Counter ) ;
23+
2224describe ( 'Timer' , function ( ) {
2325 let clock , wrappedCounter , counter ;
2426
2527 before ( ( ) => clock = sinon . useFakeTimers ( ) ) ;
2628 after ( ( ) => clock . restore ( ) ) ;
2729
2830 it ( 'should pass down a timer property alongside other props' , function ( ) {
29- const WrappedCounter = timer ( 1000 ) ( Counter ) ;
3031 expect ( WrappedCounter . displayName ) . to . equal ( 'Timer@1000[Counter]' ) ;
31-
32- const wrappedCounter = renderIntoDocument ( h ( WrappedCounter , { customProp : 1 } ) ) ;
33-
32+ wrappedCounter = renderIntoDocument ( h ( WrappedCounter , { customProp : 1 } ) ) ;
3433 counter = findRenderedComponentWithType ( wrappedCounter , Counter ) ;
3534
3635 expect ( counter . props . timer . tick ) . to . equal ( 0 ) ;
@@ -63,4 +62,18 @@ describe('Timer', function() {
6362 expect ( counter . props . timer . tick ) . to . equal ( 3 ) ;
6463 counter . props . timer . stop ( ) ;
6564 } ) ;
65+
66+ it ( 'should be synchronized with a provided value' , function ( ) {
67+ clock . restore ( ) ;
68+ clock = sinon . useFakeTimers ( 500 ) ;
69+
70+ wrappedCounter = renderIntoDocument ( h ( WrappedCounter , { synchronizeWith : 0 } ) ) ;
71+ counter = findRenderedComponentWithType ( wrappedCounter , Counter ) ;
72+
73+ expect ( counter . props . timer . tick ) . to . equal ( 0 ) ;
74+ clock . tick ( 600 ) ;
75+ expect ( counter . props . timer . tick ) . to . equal ( 1 ) ;
76+ clock . tick ( 1000 ) ;
77+ expect ( counter . props . timer . tick ) . to . equal ( 2 ) ;
78+ } ) ;
6679} ) ;
0 commit comments