Files
grafana/public/app/plugins/datasource/influxdb/components/useUniqueId.test.ts
Josh Hunt 3c6e0e8ef8 Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

25 lines
790 B
TypeScript

import { renderHook } from '@testing-library/react-hooks';
import { useUniqueId } from './useUniqueId';
describe('useUniqueId', () => {
it('should work correctly', () => {
const { result: resultA, rerender: rerenderA } = renderHook(() => useUniqueId());
const { result: resultB, rerender: rerenderB } = renderHook(() => useUniqueId());
// the values of the separate hooks should be different
expect(resultA.current).not.toBe(resultB.current);
// we copy the current values after the first render
const firstValueA = resultA.current;
const firstValueB = resultB.current;
rerenderA();
rerenderB();
// we check that the value did not change
expect(resultA.current).toBe(firstValueA);
expect(resultB.current).toBe(firstValueB);
});
});