diff options
author | Paul Slaughter <pslaughter@gitlab.com> | 2018-07-19 16:20:26 +0300 |
---|---|---|
committer | Paul Slaughter <pslaughter@gitlab.com> | 2018-07-19 22:00:17 +0300 |
commit | 133377147b893319db1353dd78322261ce92b59d (patch) | |
tree | 7ced26c46f31a1ea6c0cdf69f61bc67f11e14f3f /spec | |
parent | 66f5be832b40355bda2a56af31c112bfddedb7b1 (diff) |
Fix Web IDE router breaking on files matching "targetmode"
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/ide/ide_router_spec.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/javascripts/ide/ide_router_spec.js b/spec/javascripts/ide/ide_router_spec.js new file mode 100644 index 00000000000..52ea0882bf4 --- /dev/null +++ b/spec/javascripts/ide/ide_router_spec.js @@ -0,0 +1,44 @@ +import router from '~/ide/ide_router'; +import store from '~/ide/stores'; + +describe('IDE router', () => { + const PROJECT_NAMESPACE = 'my-group/sub-group'; + const PROJECT_NAME = 'my-project'; + + afterEach(() => { + router.push('/'); + }); + + afterAll(() => { + // VueRouter leaves this window.history at the "base" url. We need to clean this up. + window.history.replaceState({}, '', '/'); + }); + + [ + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob/`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/blob/-/src/blob`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/tree/`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/weird:branch/name-123/-/src/tree/`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/blob`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/edit`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/merge_requests/2`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/blob/-/src/blob`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/edit/blob/-/src/blob`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/merge_requests/2`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/blob`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/edit`, + `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}`, + ].forEach(route => { + it(`finds project path when route is "${route}"`, () => { + spyOn(store, 'dispatch').and.returnValue(new Promise(() => {})); + + router.push(route); + + expect(store.dispatch).toHaveBeenCalledWith('getProjectData', { + namespace: PROJECT_NAMESPACE, + projectId: PROJECT_NAME, + }); + }); + }); +}); |