mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
test(vanilla/subscribe): add test for covering fireImmediately option in 'subscribeWithSelector' (#3131)
This commit is contained in:
parent
01749b01c7
commit
a03acc3887
@ -120,4 +120,15 @@ describe('subscribe()', () => {
|
||||
expect(spy2).toHaveBeenCalledTimes(1)
|
||||
expect(spy2).toHaveBeenCalledWith(1, 0)
|
||||
})
|
||||
|
||||
it('should call listener immediately when fireImmediately is true', () => {
|
||||
const spy = vi.fn()
|
||||
const initialState = { value: 1 }
|
||||
const { subscribe } = createStore(subscribeWithSelector(() => initialState))
|
||||
|
||||
subscribe((s) => s.value, spy, { fireImmediately: true })
|
||||
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
expect(spy).toHaveBeenCalledWith(1, 1)
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user