Fix Sentry plugin tests

This commit is contained in:
Wojciech Adaszynski
2020-05-18 11:52:21 +02:00
parent 35dec7dc7c
commit 915167e950
4 changed files with 55 additions and 11 deletions
@@ -20,14 +20,19 @@ import mockFetch from 'jest-fetch-mock';
import SentryPluginPage from './SentryPluginPage';
import { ThemeProvider } from '@material-ui/core';
import { lightTheme } from '@backstage/theme';
import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core';
const errorApi = { post: () => {} };
describe('SentryPluginPage', () => {
it('should render header and time switched', () => {
mockFetch.mockResponse(() => new Promise(() => {}));
const rendered = render(
<ThemeProvider theme={lightTheme}>
<SentryPluginPage />
</ThemeProvider>,
<ApiProvider apis={ApiRegistry.from([[errorApiRef, errorApi]])}>
<ThemeProvider theme={lightTheme}>
<SentryPluginPage />
</ThemeProvider>
</ApiProvider>,
);
expect(rendered.getByText('Sentry issues')).toBeInTheDocument();
expect(rendered.getByText('24H')).toBeInTheDocument();
+1 -1
View File
@@ -18,7 +18,7 @@ import { MockSentryApi } from './mock-api';
import { ProductionSentryApi } from './production-api';
export function sentryApiFactory(organization: string): SentryApi {
if (process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV === 'production') {
return new ProductionSentryApi(organization);
}
return new MockSentryApi();