2021-03-29 08:09:14 -04:00
|
|
|
import BlobPage from '~/repository/pages/blob.vue';
|
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-09-07 17:08:26 -04:00
|
|
|
path | branch | component | componentName
|
|
|
|
${'/'} | ${'master'} | ${IndexPage} | ${'IndexPage'}
|
|
|
|
${'/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'}
|
|
|
|
${'/tree/feat(test)'} | ${'feat(test)'} | ${TreePage} | ${'TreePage'}
|
|
|
|
${'/-/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'}
|
|
|
|
${'/-/tree/master/app/assets'} | ${'master'} | ${TreePage} | ${'TreePage'}
|
|
|
|
${'/-/tree/123/app/assets'} | ${'master'} | ${null} | ${'null'}
|
2021-03-29 08:09:14 -04:00
|
|
|
${'/-/blob/master/file.md'} | ${'master'} | ${BlobPage} | ${'BlobPage'}
|
2020-04-09 11:09:29 -04:00
|
|
|
`('sets component as $componentName for path "$path"', ({ path, component, branch }) => {
|
|
|
|
const router = createRouter('', branch);
|
2019-05-20 04:41:28 -04:00
|
|
|
|
|
|
|
const componentsForRoute = router.getMatchedComponents(path);
|
|
|
|
|
|
|
|
expect(componentsForRoute.length).toBe(component ? 1 : 0);
|
|
|
|
|
|
|
|
if (component) {
|
|
|
|
expect(componentsForRoute).toContain(component);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|