2022-04-04 11:22:00 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Vue, { nextTick } from 'vue';
|
2020-05-24 23:13:21 +05:30
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
import App from '~/design_management/components/app.vue';
|
|
|
|
import DesignDetail from '~/design_management/pages/design/index.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Designs from '~/design_management/pages/index.vue';
|
2020-05-24 23:13:21 +05:30
|
|
|
import createRouter from '~/design_management/router';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { DESIGNS_ROUTE_NAME, DESIGN_ROUTE_NAME } from '~/design_management/router/constants';
|
2020-05-24 23:13:21 +05:30
|
|
|
import '~/commons/bootstrap';
|
|
|
|
|
|
|
|
function factory(routeArg) {
|
2022-04-04 11:22:00 +05:30
|
|
|
Vue.use(VueRouter);
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
window.gon = { sprite_icons: '' };
|
|
|
|
|
|
|
|
const router = createRouter('/');
|
|
|
|
if (routeArg !== undefined) {
|
|
|
|
router.push(routeArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mount(App, {
|
|
|
|
router,
|
2022-07-23 23:45:48 +05:30
|
|
|
provide: { issueIid: '1' },
|
|
|
|
stubs: { Toolbar: true },
|
2020-05-24 23:13:21 +05:30
|
|
|
mocks: {
|
|
|
|
$apollo: {
|
|
|
|
queries: {
|
2021-01-03 14:25:43 +05:30
|
|
|
designCollection: { loading: true },
|
2020-05-24 23:13:21 +05:30
|
|
|
design: { loading: true },
|
|
|
|
permissions: { loading: true },
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
mutate: jest.fn(),
|
2020-05-24 23:13:21 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Design management router', () => {
|
|
|
|
afterEach(() => {
|
|
|
|
window.location.hash = '';
|
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
describe.each([['/'], [{ name: DESIGNS_ROUTE_NAME }]])('root route', (routeArg) => {
|
2020-05-24 23:13:21 +05:30
|
|
|
it('pushes home component', () => {
|
|
|
|
const wrapper = factory(routeArg);
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(wrapper.findComponent(Designs).exists()).toBe(true);
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe.each([['/designs/1'], [{ name: DESIGN_ROUTE_NAME, params: { id: '1' } }]])(
|
|
|
|
'designs detail route',
|
2021-03-08 18:12:59 +05:30
|
|
|
(routeArg) => {
|
2020-05-24 23:13:21 +05:30
|
|
|
it('pushes designs detail component', () => {
|
|
|
|
const wrapper = factory(routeArg);
|
|
|
|
|
|
|
|
return nextTick().then(() => {
|
2022-08-27 11:52:29 +05:30
|
|
|
const detail = wrapper.findComponent(DesignDetail);
|
2020-05-24 23:13:21 +05:30
|
|
|
expect(detail.exists()).toBe(true);
|
|
|
|
expect(detail.props('id')).toEqual('1');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|