debian-mirror-gitlab/spec/frontend/repository/router_spec.js

28 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-04-29 21:17:54 +05:30
import BlobPage from '~/repository/pages/blob.vue';
2019-09-04 21:01:54 +05:30
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`
2021-06-08 01:23:25 +05:30
path | branch | component | componentName
${'/'} | ${'main'} | ${IndexPage} | ${'IndexPage'}
${'/tree/main'} | ${'main'} | ${TreePage} | ${'TreePage'}
${'/tree/feat(test)'} | ${'feat(test)'} | ${TreePage} | ${'TreePage'}
${'/-/tree/main'} | ${'main'} | ${TreePage} | ${'TreePage'}
${'/-/tree/main/app/assets'} | ${'main'} | ${TreePage} | ${'TreePage'}
${'/-/tree/123/app/assets'} | ${'main'} | ${null} | ${'null'}
${'/-/blob/main/file.md'} | ${'main'} | ${BlobPage} | ${'BlobPage'}
2020-04-22 19:07:51 +05:30
`('sets component as $componentName for path "$path"', ({ path, component, branch }) => {
const router = createRouter('', branch);
2019-09-04 21:01:54 +05:30
const componentsForRoute = router.getMatchedComponents(path);
expect(componentsForRoute.length).toBe(component ? 1 : 0);
if (component) {
expect(componentsForRoute).toContain(component);
}
});
});