import { beforeEach, describe, it, vi } from 'vitest' import { useDebounce } from './useDebounce' describe('useDebounce()', () => { let testFunc: Function let testWait: number let testImmediate: boolean beforeEach(() => { testFunc = vi.fn() testWait = 1000 testImmediate = true }) it('should be throw error if first argument passed is not function type', () => { testFunc = '' const resultFn = () => { useDebounce(testFunc, testWait, testImmediate) } expect(resultFn).toThrow(/is not a function/) }) it('should execute testFunc', () => { useDebounce(testFunc, testWait, testImmediate) expect(testFunc).toBeCalled() }) })