File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -61,4 +61,34 @@ describe('Controller', () => {
6161 expect ( await getAsyncFrames ( ctrl ) ) . toMatchSnapshot ( )
6262 } )
6363 } )
64+
65+ describe ( 'when the "onStart" prop is defined' , ( ) => {
66+ it ( 'is called once per "start" call maximum' , ( ) => {
67+ const ctrl = new Controller ( { x : 0 , y : 0 } )
68+
69+ const onStart = jest . fn ( )
70+ ctrl . start ( {
71+ x : 1 ,
72+ y : 1 ,
73+ onStart,
74+ } )
75+
76+ advanceUntilIdle ( )
77+ expect ( onStart ) . toBeCalledTimes ( 1 )
78+ } )
79+
80+ it ( 'can be different per key' , ( ) => {
81+ const ctrl = new Controller ( { x : 0 , y : 0 } )
82+
83+ const onStart1 = jest . fn ( )
84+ ctrl . start ( { x : 1 , onStart : onStart1 } )
85+
86+ const onStart2 = jest . fn ( )
87+ ctrl . start ( { y : 1 , onStart : onStart2 } )
88+
89+ advanceUntilIdle ( )
90+ expect ( onStart1 ) . toBeCalledTimes ( 1 )
91+ expect ( onStart2 ) . toBeCalledTimes ( 1 )
92+ } )
93+ } )
6494} )
You can’t perform that action at this time.
0 commit comments