grafana/public/app/plugins/datasource/influxdb/components/useUniqueId.test.ts
Gábor Farkas cbaf700d64
influxdb: switch the raw influxql editor from angular to react (#31860)
* influxdb: switch the raw influxql editor from angular to react

* influxdb: raw-influxql: better callback-naming

* influxdb: raw-influxql: use custom hook

* influxdb: flux: raw-editor: add unit tests
2021-03-16 10:47:33 +01:00

24 lines
789 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);
});
});