1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/frontend/src/hooks/useId.test.ts
Nuno Góis 5872a1c82c refactor: adapt to Vite (#940)
* chore: adapt to vite

* remove react-scripts

* add jsdom dep, update snaps

* fix tests

* fix: formatting

* fix: vercel rewrite

* fix: regeneratorRuntime is not defined

Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai>
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
2022-05-05 16:15:22 +01:00

41 lines
789 B
TypeScript

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,
}
`);
});