vitest/examples/mocks/test/self-importing.test.ts
Vladimir 7459ff8a46
fix: clear mock from callstack, if mocked with factory (#1276)
* fix: clear mock from callstack, if mocked with factory

* test: fix test for zustand
2022-05-09 11:38:11 +03:00

17 lines
401 B
TypeScript

import zustand from 'zustand'
import { magic } from '../src/zustand-magic'
vi.mock('zustand')
describe('zustand didn\'t go into an infinite loop', () => {
test('zustand is mocked', () => {
expect(vi.isMockFunction(zustand)).toBe(true)
})
test('magic calls zustand', () => {
const store = magic()
expect(zustand).toHaveBeenCalled()
expect(store).toBeTypeOf('function')
})
})