-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppLayout.test.jsx
More file actions
72 lines (69 loc) · 2.5 KB
/
AppLayout.test.jsx
File metadata and controls
72 lines (69 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import AppsRoutes, { AppsLayout } from './AppLayout';
import { MemoryRouter, Route } from 'react-router-dom';
import systemsFixture from '../../DataFiles/fixtures/DataFiles.systems.fixture';
import { projectsFixture } from '../../../redux/sagas/fixtures/projects.fixture';
import filesFixture from '../../DataFiles/fixtures/DataFiles.files.fixture';
import { appTrayExpectedFixture } from '../../../redux/sagas/fixtures/apptray.fixture';
import allocationsFixture from '../AppForm/fixtures/AppForm.allocations.fixture';
import { helloWorldAppFixture } from '../AppForm/fixtures/AppForm.app.fixture';
import { jobsFixture } from '../AppForm/fixtures/AppForm.jobs.fixture';
import renderComponent from 'utils/testing';
const mockStore = configureStore();
function renderAppsRoutes(store, appId) {
return render(
<Provider store={store}>
<MemoryRouter initialEntries={[`/applications/${appId}`]}>
<Route path="/:appId?">
<AppsRoutes />
</Route>
</MemoryRouter>
</Provider>
);
}
describe('AppsLayout', () => {
it('should show a loading spinner while fetching data', () => {
const store = mockStore({
apps: { ...appTrayExpectedFixture, loading: true, categoryDict: {} },
});
const { getByTestId } = renderComponent(<AppsLayout />, store);
expect(getByTestId('loading-spinner')).toBeDefined();
});
it('Display the correct error message', () => {
const store = mockStore({
apps: { ...appTrayExpectedFixture, error: { isError: true } },
});
const { getByText } = renderComponent(<AppsLayout />, store);
expect(getByText('Something went wrong.')).toBeDefined();
});
});
describe('AppsHeader', () => {
it('renders breadcrumbs', () => {
const store = mockStore({
systems: systemsFixture,
projects: projectsFixture,
jobs: jobsFixture,
files: filesFixture,
apps: appTrayExpectedFixture,
allocations: allocationsFixture,
app: {
error: {
isError: false,
},
...helloWorldAppFixture,
},
pushKeys: {
modals: filesFixture.modals,
modalProps: filesFixture.modalProps,
},
workbench: {
config: { hideManageAccount: false },
},
});
let { getByText } = renderAppsRoutes(store, 'arraytest-0.1');
expect(getByText(/Applications \/ Array Test/)).toBeDefined();
});
});