Skip to content

Commit e5cf72c

Browse files
committed
test: the "onStart" prop of Controller
1 parent 4675227 commit e5cf72c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

packages/core/src/Controller.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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
})

0 commit comments

Comments
 (0)