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 kibana-management
  • Loading branch information
eokoneyo committed Nov 21, 2024
1 parent 51a84eb commit cd5d5f9
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ describe('NumberInput', () => {
expect(input).toBeDisabled();
});

it('recovers if value is null', () => {
it('recovers if value is null', async () => {
const { getByTestId } = render(
wrap(<NumberInput {...defaultProps} field={{ ...defaultProps.field, defaultValue: null }} />)
);
const input = getByTestId(`${TEST_SUBJ_PREFIX_FIELD}-${id}`);
waitFor(() => expect(input).toHaveValue(undefined));

await waitFor(() => expect(getByTestId(`${TEST_SUBJ_PREFIX_FIELD}-${id}`)).toHaveValue(null));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*/

import { createMemoryHistory } from 'history';
import { renderHook, act, cleanup } from '@testing-library/react-hooks';

import { renderHook, act, cleanup, waitFor } from '@testing-library/react';

import { coreMock } from '@kbn/core/public/mocks';
import { CoreScopedHistory } from '@kbn/core/public';
Expand Down Expand Up @@ -73,7 +74,7 @@ describe('useUnsavedChangesPrompt', () => {
act(() => history.push('/test'));

// needed because we have an async useEffect
await act(() => new Promise((resolve) => resolve()));
await waitFor(() => new Promise((resolve) => resolve(null)));

expect(navigateToUrl).toBeCalledWith('/mock/test', expect.anything());
expect(coreStart.overlays.openConfirm).toBeCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { renderHook, act } from '@testing-library/react-hooks';
import { renderHook, act } from '@testing-library/react';
import { useSetInitialValue } from './use_set_initial_value';
import { IToasts } from '@kbn/core-notifications-browser';
import { decompressFromEncodedURIComponent } from 'lz-string';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';

import { useComponentTemplatesContext } from '../../component_templates_context';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import { useStepFromQueryString } from './use_step_from_query_string';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { CustomInferenceEndpointConfig, SemanticTextField } from '../../../../../types';
import { useSemanticText } from './use_semantic_text';
import { act } from 'react-dom/test-utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { coreMock } from '@kbn/core/public/mocks';
import { createMemoryHistory } from 'history';
import { useRedirectPath } from './redirect_path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { NormalizedFields } from '../application/components/mappings_editor/types';
import { useDetailsPageMappingsModelManagement } from './use_details_page_mappings_model_management';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import { useRedirectPath } from './redirect_path';
import { useKibana } from '../../shared_imports';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';

import { useCollapsibleList } from './use_collapsible_list';

Expand Down

0 comments on commit cd5d5f9

Please sign in to comment.