Skip to content

Commit

Permalink
[React18] Migrated test suites to accommodate changes to testing libr…
Browse files Browse the repository at this point in the history
…ary owned by security-detection-engine
  • Loading branch information
eokoneyo committed Nov 22, 2024
1 parent 11d8f0c commit 861764d
Show file tree
Hide file tree
Showing 32 changed files with 961 additions and 1,186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

import { DataViewFieldBase } from '@kbn/es-query';
import { ReactElement } from 'react';
import { act } from '@testing-library/react';

import { renderHook } from '@testing-library/react-hooks';
import TestRenderer from 'react-test-renderer';
const { act: actTestRenderer } = TestRenderer;
import { act, renderHook } from '@testing-library/react';

import { fields } from '../../fields/index.mock';
import { useEsField } from '../use_es_field';
Expand Down Expand Up @@ -480,7 +476,7 @@ describe('useField', () => {
useEsField({ indexPattern, onChange: onChangeMock, isRequired: true })
);

actTestRenderer(() => {
act(() => {
result.current.handleTouch();
});
expect(result.current.isInvalid).toBeTruthy();
Expand All @@ -490,15 +486,15 @@ describe('useField', () => {
useEsField({ indexPattern, onChange: onChangeMock, isRequired: true, selectedField })
);

actTestRenderer(() => {
act(() => {
result.current.handleTouch();
});
expect(result.current.isInvalid).toBeFalsy();
});
it('should return isInvalid equals false when isRequired is false', () => {
const { result } = renderHook(() => useEsField({ indexPattern, onChange: onChangeMock }));

actTestRenderer(() => {
act(() => {
result.current.handleTouch();
});
expect(result.current.isInvalid).toBeFalsy();
Expand Down
Loading

0 comments on commit 861764d

Please sign in to comment.