diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:09:10 +0300 |
commit | b98fa9ef3d5bead417ae2f325cb64637883264e9 (patch) | |
tree | 409f2002dd056f12d82d3959b3e6f012c4087123 /spec/frontend/vue_shared/components/file_row_spec.js | |
parent | 7e3005967df23a957fe1998c8de4f50b412e69e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components/file_row_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/components/file_row_spec.js | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/spec/frontend/vue_shared/components/file_row_spec.js b/spec/frontend/vue_shared/components/file_row_spec.js index 420281e844c..b3ced84ddb5 100644 --- a/spec/frontend/vue_shared/components/file_row_spec.js +++ b/spec/frontend/vue_shared/components/file_row_spec.js @@ -1,13 +1,19 @@ import { file } from 'jest/ide/helpers'; import FileRow from '~/vue_shared/components/file_row.vue'; -import { mount } from '@vue/test-utils'; +import FileHeader from '~/vue_shared/components/file_row_header.vue'; +import { shallowMount } from '@vue/test-utils'; +import { nextTick } from 'vue'; +import { escapeFileUrl } from '~/lib/utils/url_utility'; describe('File row component', () => { let wrapper; - function createComponent(propsData) { - wrapper = mount(FileRow, { + function createComponent(propsData, $router = undefined) { + wrapper = shallowMount(FileRow, { propsData, + mocks: { + $router, + }, }); } @@ -61,7 +67,7 @@ describe('File row component', () => { }), }); - return wrapper.vm.$nextTick().then(() => { + return nextTick().then(() => { expect(wrapper.vm.scrollIntoView).toHaveBeenCalled(); }); }); @@ -85,6 +91,27 @@ describe('File row component', () => { level: 0, }); - expect(wrapper.element.classList).toContain('js-file-row-header'); + expect(wrapper.contains(FileHeader)).toBe(true); + }); + + it('matches the current route against encoded file URL', () => { + const fileName = 'with space'; + const rowFile = Object.assign({}, file(fileName), { + url: `/${fileName}`, + }); + const routerPath = `/project/${escapeFileUrl(fileName)}`; + createComponent( + { + file: rowFile, + level: 0, + }, + { + currentRoute: { + path: routerPath, + }, + }, + ); + + expect(wrapper.vm.hasUrlAtCurrentRoute()).toBe(true); }); }); |