Skip to content

Commit

Permalink
fix: unit test
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Oct 12, 2023
1 parent d1bd685 commit 2c79849
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import React from 'react';
import { IntlProvider } from 'react-intl';
import { fireEvent, render, waitFor } from '@testing-library/react';
import { WorkspaceFatalError } from './workspace_fatal_error';
import { context } from '../../../../opensearch_dashboards_react/public';
import { coreMock } from '../../../../../core/public/mocks';

describe('<WorkspaceFatalError />', () => {
it('render normally', async () => {
Expand Down Expand Up @@ -41,9 +43,18 @@ describe('<WorkspaceFatalError />', () => {
get: () => 'http://localhost/',
set: setHrefSpy,
});
const coreStartMock = coreMock.createStart();
const { getByText } = render(
<IntlProvider locale="en">
<WorkspaceFatalError error="errorInCallout" />
<context.Provider
value={
{
services: coreStartMock,
} as any
}
>
<WorkspaceFatalError error="errorInCallout" />
</context.Provider>
</IntlProvider>
);
fireEvent.click(getByText('Go back to home'));
Expand Down

0 comments on commit 2c79849

Please sign in to comment.