2019-05-20 04:41:28 -04:00
|
|
|
import IndexPage from '~/repository/pages/index.vue';
|
|
|
|
import TreePage from '~/repository/pages/tree.vue';
|
|
|
|
import createRouter from '~/repository/router';
|
|
|
|
|
|
|
|
describe('Repository router spec', () => {
|
|
|
|
it.each`
|
2020-01-27 07:08:35 -05:00
|
|
|
path | component | componentName
|
|
|
|
${'/'} | ${IndexPage} | ${'IndexPage'}
|
2020-02-05 10:08:48 -05:00
|
|
|
${'/tree/master'} | ${TreePage} | ${'TreePage'}
|
2020-01-27 07:08:35 -05:00
|
|
|
${'/-/tree/master'} | ${TreePage} | ${'TreePage'}
|
|
|
|
${'/-/tree/master/app/assets'} | ${TreePage} | ${'TreePage'}
|
|
|
|
${'/-/tree/123/app/assets'} | ${null} | ${'null'}
|
2019-05-20 04:41:28 -04:00
|
|
|
`('sets component as $componentName for path "$path"', ({ path, component }) => {
|
|
|
|
const router = createRouter('', 'master');
|
|
|
|
|
|
|
|
const componentsForRoute = router.getMatchedComponents(path);
|
|
|
|
|
|
|
|
expect(componentsForRoute.length).toBe(component ? 1 : 0);
|
|
|
|
|
|
|
|
if (component) {
|
|
|
|
expect(componentsForRoute).toContain(component);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|