Add index.test.ts and plugin.test.tsx
Signed-off-by: Karan Shah <karan.shah@simplybusiness.co.uk>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
"react": "^16.13.1 || ^17.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/app-defaults": "^0.1.2",
|
||||
"@backstage/cli": "^0.10.2",
|
||||
"@backstage/core-app-api": "^0.2.1",
|
||||
"@backstage/dev-utils": "^0.2.14",
|
||||
@@ -42,7 +43,8 @@
|
||||
"@types/jest": "*",
|
||||
"@types/node": "*",
|
||||
"msw": "^0.35.0",
|
||||
"cross-fetch": "^3.0.6"
|
||||
"cross-fetch": "^3.0.6",
|
||||
"react-router": "6.0.0-beta.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { airbrakePlugin } from './plugin';
|
||||
import { AirbrakePage, airbrakePlugin } from './index';
|
||||
|
||||
describe('airbrake', () => {
|
||||
it('should export plugin', () => {
|
||||
expect(airbrakePlugin).toBeDefined();
|
||||
describe('The demo index page', () => {
|
||||
it('exports the plugin and page', async () => {
|
||||
expect(AirbrakePage).toBeTruthy();
|
||||
expect(airbrakePlugin).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2021 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { AirbrakePage, airbrakePlugin } from './plugin';
|
||||
import { renderWithEffects } from '@backstage/test-utils';
|
||||
import { createApp } from '@backstage/app-defaults';
|
||||
import { Route } from 'react-router';
|
||||
|
||||
describe('Airbrake', () => {
|
||||
it('should export plugin', () => {
|
||||
expect(airbrakePlugin).toBeDefined();
|
||||
});
|
||||
|
||||
it('should render page', async () => {
|
||||
process.env = {
|
||||
NODE_ENV: 'test',
|
||||
APP_CONFIG: [
|
||||
{
|
||||
data: {
|
||||
app: { title: 'Test' },
|
||||
backend: { baseUrl: 'http://localhost:7000' },
|
||||
techdocs: {
|
||||
storageUrl: 'http://localhost:7000/api/techdocs/static/docs',
|
||||
},
|
||||
},
|
||||
context: 'test',
|
||||
},
|
||||
] as any,
|
||||
};
|
||||
|
||||
const app = createApp();
|
||||
const AppProvider = app.getProvider();
|
||||
const AppRouter = app.getRouter();
|
||||
|
||||
const rendered = await renderWithEffects(
|
||||
<AppProvider>
|
||||
<AppRouter>
|
||||
<Route path="/airbrake" element={<AirbrakePage />} />
|
||||
</AppRouter>
|
||||
</AppProvider>,
|
||||
);
|
||||
expect(rendered.baseElement).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user