react-use/tests/resolveHookState.test.ts
streamich ad9a0bd313 test: 💍 enable hidden tests
Two test files did not have ".test" in their name, which would make Jest
to skip them.
2019-11-10 23:54:31 +01:00

27 lines
748 B
TypeScript

import { resolveHookState } from '../src/util/resolveHookState';
describe('resolveHookState', () => {
it('should defined', () => {
expect(resolveHookState).toBeDefined();
});
it(`should return value as is if it's not a function`, () => {
expect(resolveHookState(1)).toBe(1);
expect(resolveHookState('HI!')).toBe('HI!');
expect(resolveHookState(undefined)).toBe(undefined);
});
it('should call passed function', () => {
const spy = jest.fn();
resolveHookState(spy);
expect(spy).toHaveBeenCalled();
});
it('should pass 2nd parameter to function', () => {
const spy = jest.fn();
resolveHookState(spy, 123);
expect(spy).toHaveBeenCalled();
expect(spy.mock.calls[0][0]).toBe(123);
});
});