1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 08:48:05 +00:00
thatmattlove-hyperglass/hyperglass/ui/hooks/use-boolean-value.test.tsx
2023-04-13 21:43:20 -04:00

20 lines
704 B
TypeScript

import { renderHook } from '@testing-library/react';
import '@testing-library/jest-dom';
import { useBooleanValue } from './use-boolean-value';
const VALUE_IF_TRUE = 'Is True';
const VALUE_IF_FALSE = 'Is False';
describe('useBooleanValue Hook', () => {
it('text should reflect boolean state', () => {
const { result, rerender } = renderHook(
({ initial }) => useBooleanValue(initial, VALUE_IF_TRUE, VALUE_IF_FALSE),
{ initialProps: { initial: false } },
);
expect(result.current).toBe(VALUE_IF_FALSE);
rerender({ initial: true });
expect(result.current).toBe(VALUE_IF_TRUE);
rerender({ initial: false });
expect(result.current).toBe(VALUE_IF_FALSE);
});
});