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`
|
2021-04-21 08:09:16 -04:00
|
|
|
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-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);
|
|
|
|
}
|
|
|
|
});
|
2021-10-11 02:13:09 -04:00
|
|
|
|
|
|
|
describe('Storing Web IDE path globally', () => {
|
|
|
|
const proj = 'foo-bar-group/foo-bar-proj';
|
|
|
|
let originalGl;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
originalGl = window.gl;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
window.gl = originalGl;
|
|
|
|
});
|
|
|
|
|
|
|
|
it.each`
|
|
|
|
path | branch | expectedPath
|
|
|
|
${'/'} | ${'main'} | ${`/-/ide/project/${proj}/edit/main/-/`}
|
|
|
|
${'/tree/main'} | ${'main'} | ${`/-/ide/project/${proj}/edit/main/-/`}
|
|
|
|
${'/tree/feat(test)'} | ${'feat(test)'} | ${`/-/ide/project/${proj}/edit/feat(test)/-/`}
|
|
|
|
${'/-/tree/main'} | ${'main'} | ${`/-/ide/project/${proj}/edit/main/-/`}
|
|
|
|
${'/-/tree/main/app/assets'} | ${'main'} | ${`/-/ide/project/${proj}/edit/main/-/app/assets/`}
|
|
|
|
${'/-/blob/main/file.md'} | ${'main'} | ${`/-/ide/project/${proj}/edit/main/-/file.md`}
|
|
|
|
`('generates the correct Web IDE url for $path', ({ path, branch, expectedPath } = {}) => {
|
|
|
|
const router = createRouter(proj, branch);
|
|
|
|
|
|
|
|
router.push(path);
|
|
|
|
expect(window.gl.webIDEPath).toBe(expectedPath);
|
|
|
|
});
|
|
|
|
});
|
2019-05-20 04:41:28 -04:00
|
|
|
});
|