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 Dec 10, 2024
1 parent 101e797 commit 4b4c982
Show file tree
Hide file tree
Showing 31 changed files with 959 additions and 1,185 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 4b4c982

Please sign in to comment.