Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 18:09:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 18:09:37 +0300
commit2c89e169769ead722394a79ed67fcd08e96863dd (patch)
tree0dadb576846c484475b895f75fab41f71cdb952e /spec/frontend/ide
parentbd497e352ebd279536ae11855871162e82a3f88c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide')
-rw-r--r--spec/frontend/ide/ide_router_extension_spec.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/frontend/ide/ide_router_extension_spec.js b/spec/frontend/ide/ide_router_extension_spec.js
new file mode 100644
index 00000000000..3e29ecc4a90
--- /dev/null
+++ b/spec/frontend/ide/ide_router_extension_spec.js
@@ -0,0 +1,48 @@
+import VueRouter from 'vue-router';
+import IdeRouter from '~/ide/ide_router_extension';
+
+jest.mock('vue-router');
+
+describe('IDE overrides of VueRouter', () => {
+ const paths = branch => [
+ `${branch}`,
+ `/${branch}`,
+ `/${branch}/-/`,
+ `/edit/${branch}`,
+ `/edit/${branch}/-/`,
+ `/blob/${branch}`,
+ `/blob/${branch}/-/`,
+ `/blob/${branch}/-/src/merge_requests/2`,
+ `/blob/${branch}/-/src/blob/`,
+ `/tree/${branch}/-/src/blob/`,
+ `/tree/${branch}/-/src/tree/`,
+ ];
+ let router;
+
+ beforeEach(() => {
+ VueRouter.mockClear();
+ router = new IdeRouter({
+ mode: 'history',
+ });
+ });
+
+ it.each`
+ path | expected
+ ${'#-test'} | ${'%23-test'}
+ ${'#test'} | ${'%23test'}
+ ${'test#'} | ${'test%23'}
+ ${'test-#'} | ${'test-%23'}
+ ${'test-#-hash'} | ${'test-%23-hash'}
+ ${'test/hash#123'} | ${'test/hash%23123'}
+ `('finds project path when route is $path', ({ path, expected }) => {
+ paths(path).forEach(route => {
+ const expectedPath = route.replace(path, expected);
+
+ router.push(route);
+ expect(VueRouter.prototype.push).toHaveBeenCalledWith(expectedPath, undefined, undefined);
+
+ router.resolve(route);
+ expect(VueRouter.prototype.resolve).toHaveBeenCalledWith(expectedPath, undefined, undefined);
+ });
+ });
+});