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 obs-knowledge-team,obs-ux-infra_services-team
  • Loading branch information
eokoneyo committed Nov 21, 2024
1 parent 51a84eb commit e065d2c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useContainerMetricsTable } from './use_container_metrics_table';
import { useInfrastructureNodeMetrics } from '../shared';
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { createMetricsClientMock } from '../test_helpers';

jest.mock('../shared', () => ({
Expand All @@ -33,6 +33,12 @@ describe('useContainerMetricsTable hook', () => {
},
};

// include this to prevent rendering error in test
useInfrastructureNodeMetricsMock.mockReturnValue({
isLoading: true,
data: { state: 'empty-indices' },
});

renderHook(() =>
useContainerMetricsTable({
timerange: { from: 'now-30d', to: 'now' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useHostMetricsTable } from './use_host_metrics_table';
import { useInfrastructureNodeMetrics } from '../shared';
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { createMetricsClientMock } from '../test_helpers';

jest.mock('../shared', () => ({
Expand Down Expand Up @@ -40,6 +40,12 @@ describe('useHostMetricsTable hook', () => {
},
};

// include this to prevent rendering error in test
useInfrastructureNodeMetricsMock.mockReturnValue({
isLoading: true,
data: { state: 'empty-indices' },
});

renderHook(() =>
useHostMetricsTable({
timerange: { from: 'now-30d', to: 'now' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { usePodMetricsTable } from './use_pod_metrics_table';
import { useInfrastructureNodeMetrics } from '../shared';
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { createMetricsClientMock } from '../test_helpers';

jest.mock('../shared', () => ({
Expand All @@ -33,6 +33,12 @@ describe('usePodMetricsTable hook', () => {
},
};

// include this to prevent rendering error in test
useInfrastructureNodeMetricsMock.mockReturnValue({
isLoading: true,
data: { state: 'empty-indices' },
});

renderHook(() =>
usePodMetricsTable({
timerange: { from: 'now-30d', to: 'now' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { coreMock } from '@kbn/core/public/mocks';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
Expand Down

0 comments on commit e065d2c

Please sign in to comment.