react-use/tests/resolveHookState.ts
Anton Zinovyev 8de2a3ee13 chore: move tests to top level /tests folder
chore: move all the tests to the separate directory outside of sources;

chore: remove jest.config.js (config moved to the package.json);

test: unused import in test;

test: 💍 fix tests add back x and y to useMeasure

chore: 🤖 add linter to /tests folder

ci: 🎡 limit Jest worker count for CircleCI
2019-11-08 16:55:34 -05:00

27 lines
744 B
TypeScript

import { resolveHookState } from '../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);
});
});