2022-04-21 08:26:49 +02:00
|
|
|
import { useId } from 'hooks/useId';
|
|
|
|
import { renderHook } from '@testing-library/react-hooks';
|
|
|
|
|
|
|
|
test('useId', () => {
|
|
|
|
const { result, rerender } = renderHook(() => useId());
|
|
|
|
|
|
|
|
rerender();
|
|
|
|
rerender();
|
|
|
|
|
|
|
|
expect(result).toMatchInlineSnapshot(`
|
2022-05-05 17:15:22 +02:00
|
|
|
{
|
|
|
|
"all": [
|
|
|
|
"useId-0",
|
|
|
|
"useId-0",
|
|
|
|
"useId-0",
|
|
|
|
],
|
|
|
|
"current": "useId-0",
|
|
|
|
"error": undefined,
|
|
|
|
}
|
2022-04-21 08:26:49 +02:00
|
|
|
`);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('useId prefix', () => {
|
|
|
|
const { result, rerender } = renderHook(() => useId('prefix'));
|
|
|
|
|
|
|
|
rerender();
|
|
|
|
rerender();
|
|
|
|
|
|
|
|
expect(result).toMatchInlineSnapshot(`
|
2022-05-05 17:15:22 +02:00
|
|
|
{
|
|
|
|
"all": [
|
|
|
|
"prefix-1",
|
|
|
|
"prefix-1",
|
|
|
|
"prefix-1",
|
|
|
|
],
|
|
|
|
"current": "prefix-1",
|
|
|
|
"error": undefined,
|
|
|
|
}
|
2022-04-21 08:26:49 +02:00
|
|
|
`);
|
|
|
|
});
|