2021-10-19 08:12:07 -04:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import App from '~/work_items/components/app.vue';
|
2021-11-23 10:11:19 -05:00
|
|
|
import CreateWorkItem from '~/work_items/pages/create_work_item.vue';
|
2021-10-19 08:12:07 -04:00
|
|
|
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-02-09 13:16:19 -05:00
|
|
|
provide: {
|
|
|
|
fullPath: 'full-path',
|
|
|
|
},
|
|
|
|
mocks: {
|
|
|
|
$apollo: {
|
|
|
|
queries: {
|
2022-03-10 01:09:00 -05:00
|
|
|
workItem: {},
|
2022-02-09 13:16:19 -05:00
|
|
|
workItemTypes: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-19 08:12:07 -04:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
window.location.hash = '';
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders work item on `/1` route', async () => {
|
|
|
|
await createComponent('/1');
|
|
|
|
|
2022-03-24 11:09:10 -04:00
|
|
|
expect(wrapper.findComponent(WorkItemsRoot).exists()).toBe(true);
|
2021-10-19 08:12:07 -04:00
|
|
|
});
|
2021-11-23 10:11:19 -05:00
|
|
|
|
|
|
|
it('renders create work item page on `/new` route', async () => {
|
|
|
|
await createComponent('/new');
|
|
|
|
|
|
|
|
expect(wrapper.findComponent(CreateWorkItem).exists()).toBe(true);
|
|
|
|
});
|
2021-10-19 08:12:07 -04:00
|
|
|
});
|