blob: 1b5c86c19cb6317d8e671f7b5bd29c8a769638a4 (
plain)
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
|
import { shallowMount } from '@vue/test-utils';
import { createRouter } from '~/ci/catalog/router';
import ciResourceDetailsPage from '~/ci/catalog/components/pages/ci_resource_details_page.vue';
import CiCatalogHome from '~/ci/catalog/components/ci_catalog_home.vue';
describe('CiCatalogHome', () => {
const defaultProps = {};
const baseRoute = '/';
const resourcesPageComponentStub = {
name: 'page-component',
template: '<div>Hello</div>',
};
const router = createRouter(baseRoute, resourcesPageComponentStub);
const createComponent = ({ props = {} } = {}) => {
shallowMount(CiCatalogHome, {
propsData: {
...defaultProps,
...props,
},
router,
});
};
describe('when mounted', () => {
beforeEach(() => {
createComponent();
});
describe('router', () => {
it.each`
path | component
${baseRoute} | ${resourcesPageComponentStub}
${'/1'} | ${ciResourceDetailsPage}
`('when route is $path it renders the right component', async ({ path, component }) => {
if (path !== '/') {
await router.push(path);
}
const [root] = router.currentRoute.matched;
expect(root.components.default).toBe(component);
});
});
});
});
|