1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/frontend/src/hooks/useId.test.ts

41 lines
789 B
TypeScript
Raw Normal View History

import { useId } from 'hooks/useId';
import { renderHook } from '@testing-library/react-hooks';
test('useId', () => {
const { result, rerender } = renderHook(() => useId());
rerender();
rerender();
expect(result).toMatchInlineSnapshot(`
{
"all": [
"useId-0",
"useId-0",
"useId-0",
],
"current": "useId-0",
"error": undefined,
}
`);
});
test('useId prefix', () => {
const { result, rerender } = renderHook(() => useId('prefix'));
rerender();
rerender();
expect(result).toMatchInlineSnapshot(`
{
"all": [
"prefix-1",
"prefix-1",
"prefix-1",
],
"current": "prefix-1",
"error": undefined,
}
`);
});