debian-mirror-gitlab/spec/frontend/work_items/router_spec.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-12-11 22:18:48 +05:30
import { mount } from '@vue/test-utils';
import App from '~/work_items/components/app.vue';
2022-01-26 12:08:38 +05:30
import CreateWorkItem from '~/work_items/pages/create_work_item.vue';
2021-12-11 22:18:48 +05:30
import WorkItemsRoot from '~/work_items/pages/work_item_root.vue';
import { createRouter } from '~/work_items/router';
describe('Work items router', () => {
let wrapper;
const createComponent = async (routeArg) => {
const router = createRouter('/work_item');
if (routeArg !== undefined) {
await router.push(routeArg);
}
wrapper = mount(App, {
router,
2022-04-04 11:22:00 +05:30
provide: {
fullPath: 'full-path',
},
mocks: {
$apollo: {
queries: {
workItemTypes: {},
},
},
},
2021-12-11 22:18:48 +05:30
});
};
afterEach(() => {
wrapper.destroy();
window.location.hash = '';
});
it('renders work item on `/1` route', async () => {
await createComponent('/1');
expect(wrapper.find(WorkItemsRoot).exists()).toBe(true);
});
2022-01-26 12:08:38 +05:30
it('renders create work item page on `/new` route', async () => {
await createComponent('/new');
expect(wrapper.findComponent(CreateWorkItem).exists()).toBe(true);
});
2021-12-11 22:18:48 +05:30
});