2022-01-21 10:13:54 -05:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Vue, { nextTick } from 'vue';
|
2020-05-07 08:09:46 -04:00
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
import App from '~/design_management/components/app.vue';
|
|
|
|
import DesignDetail from '~/design_management/pages/design/index.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import Designs from '~/design_management/pages/index.vue';
|
2020-05-07 08:09:46 -04:00
|
|
|
import createRouter from '~/design_management/router';
|
2020-07-28 08:09:49 -04:00
|
|
|
import { DESIGNS_ROUTE_NAME, DESIGN_ROUTE_NAME } from '~/design_management/router/constants';
|
2020-05-07 08:09:46 -04:00
|
|
|
import '~/commons/bootstrap';
|
|
|
|
|
2020-05-08 05:09:39 -04:00
|
|
|
function factory(routeArg) {
|
2022-01-21 10:13:54 -05:00
|
|
|
Vue.use(VueRouter);
|
2020-05-07 08:09:46 -04:00
|
|
|
|
2020-05-08 05:09:39 -04:00
|
|
|
window.gon = { sprite_icons: '' };
|
2020-05-07 08:09:46 -04:00
|
|
|
|
2020-05-08 05:09:39 -04:00
|
|
|
const router = createRouter('/');
|
|
|
|
if (routeArg !== undefined) {
|
|
|
|
router.push(routeArg);
|
|
|
|
}
|
2020-05-07 08:09:46 -04:00
|
|
|
|
2020-05-08 05:09:39 -04:00
|
|
|
return mount(App, {
|
|
|
|
router,
|
|
|
|
mocks: {
|
|
|
|
$apollo: {
|
|
|
|
queries: {
|
2020-09-22 11:09:37 -04:00
|
|
|
designCollection: { loading: true },
|
2020-05-08 05:09:39 -04:00
|
|
|
design: { loading: true },
|
|
|
|
permissions: { loading: true },
|
2020-05-07 08:09:46 -04:00
|
|
|
},
|
2020-05-20 05:08:11 -04:00
|
|
|
mutate: jest.fn(),
|
2020-05-07 08:09:46 -04:00
|
|
|
},
|
2020-05-08 05:09:39 -04:00
|
|
|
},
|
2020-05-07 08:09:46 -04:00
|
|
|
});
|
2020-05-08 05:09:39 -04:00
|
|
|
}
|
2020-05-07 08:09:46 -04:00
|
|
|
|
2020-05-08 05:09:39 -04:00
|
|
|
describe('Design management router', () => {
|
|
|
|
afterEach(() => {
|
2020-05-07 08:09:46 -04:00
|
|
|
window.location.hash = '';
|
|
|
|
});
|
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
describe.each([['/'], [{ name: DESIGNS_ROUTE_NAME }]])('root route', (routeArg) => {
|
2020-05-07 08:09:46 -04:00
|
|
|
it('pushes home component', () => {
|
2020-05-08 05:09:39 -04:00
|
|
|
const wrapper = factory(routeArg);
|
2020-05-07 08:09:46 -04:00
|
|
|
|
2020-05-08 05:09:39 -04:00
|
|
|
expect(wrapper.find(Designs).exists()).toBe(true);
|
2020-05-07 08:09:46 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe.each([['/designs/1'], [{ name: DESIGN_ROUTE_NAME, params: { id: '1' } }]])(
|
|
|
|
'designs detail route',
|
2020-12-23 16:10:24 -05:00
|
|
|
(routeArg) => {
|
2020-05-07 08:09:46 -04:00
|
|
|
it('pushes designs detail component', () => {
|
2020-05-08 05:09:39 -04:00
|
|
|
const wrapper = factory(routeArg);
|
2020-05-07 08:09:46 -04:00
|
|
|
|
2020-05-08 05:09:39 -04:00
|
|
|
return nextTick().then(() => {
|
|
|
|
const detail = wrapper.find(DesignDetail);
|
2020-05-07 08:09:46 -04:00
|
|
|
expect(detail.exists()).toBe(true);
|
|
|
|
expect(detail.props('id')).toEqual('1');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|