diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 21:09:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 21:09:46 +0300 |
commit | aca82d5ba49a8d2cf7ca30ac4ee6dcbd62b47cff (patch) | |
tree | 3ce0eff868aab025bc85c37d921582217f4c69f9 /spec/frontend/code_navigation | |
parent | 8a840df2e433bc39d033b20e64402fa3f56445d3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/code_navigation')
4 files changed, 56 insertions, 15 deletions
diff --git a/spec/frontend/code_navigation/components/__snapshots__/popover_spec.js.snap b/spec/frontend/code_navigation/components/__snapshots__/popover_spec.js.snap index c1534022242..c9fdd388585 100644 --- a/spec/frontend/code_navigation/components/__snapshots__/popover_spec.js.snap +++ b/spec/frontend/code_navigation/components/__snapshots__/popover_spec.js.snap @@ -23,17 +23,20 @@ exports[`Code navigation popover component renders popover 1`] = ` <div class="popover-body" > - <gl-deprecated-button-stub + <gl-button-stub + category="tertiary" class="w-100" - href="http://test.com" - size="md" + data-testid="go-to-definition-btn" + href="http://gitlab.com/test.js#L20" + icon="" + size="medium" target="_blank" variant="default" > Go to definition - </gl-deprecated-button-stub> + </gl-button-stub> </div> </div> `; diff --git a/spec/frontend/code_navigation/components/app_spec.js b/spec/frontend/code_navigation/components/app_spec.js index d5693cc4173..6dfc81dcc40 100644 --- a/spec/frontend/code_navigation/components/app_spec.js +++ b/spec/frontend/code_navigation/components/app_spec.js @@ -48,6 +48,7 @@ describe('Code navigation app component', () => { factory({ currentDefinition: { hover: 'console' }, currentDefinitionPosition: { x: 0 }, + currentBlobPath: 'index.js', }); expect(wrapper.find(Popover).exists()).toBe(true); diff --git a/spec/frontend/code_navigation/components/popover_spec.js b/spec/frontend/code_navigation/components/popover_spec.js index df3bbc7c1c6..858e94cf155 100644 --- a/spec/frontend/code_navigation/components/popover_spec.js +++ b/spec/frontend/code_navigation/components/popover_spec.js @@ -1,7 +1,7 @@ import { shallowMount } from '@vue/test-utils'; import Popover from '~/code_navigation/components/popover.vue'; -const DEFINITION_PATH_PREFIX = 'http:/'; +const DEFINITION_PATH_PREFIX = 'http://gitlab.com'; const MOCK_CODE_DATA = Object.freeze({ hover: [ @@ -10,7 +10,7 @@ const MOCK_CODE_DATA = Object.freeze({ value: 'console.log', }, ], - definition_path: 'test.com', + definition_path: 'test.js#L20', }); const MOCK_DOCS_DATA = Object.freeze({ @@ -20,13 +20,15 @@ const MOCK_DOCS_DATA = Object.freeze({ value: 'console.log', }, ], - definition_path: 'test.com', + definition_path: 'test.js#L20', }); let wrapper; -function factory(position, data, definitionPathPrefix) { - wrapper = shallowMount(Popover, { propsData: { position, data, definitionPathPrefix } }); +function factory({ position, data, definitionPathPrefix, blobPath = 'index.js' }) { + wrapper = shallowMount(Popover, { + propsData: { position, data, definitionPathPrefix, blobPath }, + }); } describe('Code navigation popover component', () => { @@ -35,14 +37,33 @@ describe('Code navigation popover component', () => { }); it('renders popover', () => { - factory({ x: 0, y: 0, height: 0 }, MOCK_CODE_DATA, DEFINITION_PATH_PREFIX); + factory({ + position: { x: 0, y: 0, height: 0 }, + data: MOCK_CODE_DATA, + definitionPathPrefix: DEFINITION_PATH_PREFIX, + }); expect(wrapper.element).toMatchSnapshot(); }); + it('renders link with hash to current file', () => { + factory({ + position: { x: 0, y: 0, height: 0 }, + data: MOCK_CODE_DATA, + definitionPathPrefix: DEFINITION_PATH_PREFIX, + blobPath: 'test.js', + }); + + expect(wrapper.find('[data-testid="go-to-definition-btn"]').attributes('href')).toBe('#L20'); + }); + describe('code output', () => { it('renders code output', () => { - factory({ x: 0, y: 0, height: 0 }, MOCK_CODE_DATA, DEFINITION_PATH_PREFIX); + factory({ + position: { x: 0, y: 0, height: 0 }, + data: MOCK_CODE_DATA, + definitionPathPrefix: DEFINITION_PATH_PREFIX, + }); expect(wrapper.find({ ref: 'code-output' }).exists()).toBe(true); expect(wrapper.find({ ref: 'doc-output' }).exists()).toBe(false); @@ -51,7 +72,11 @@ describe('Code navigation popover component', () => { describe('documentation output', () => { it('renders code output', () => { - factory({ x: 0, y: 0, height: 0 }, MOCK_DOCS_DATA, DEFINITION_PATH_PREFIX); + factory({ + position: { x: 0, y: 0, height: 0 }, + data: MOCK_DOCS_DATA, + definitionPathPrefix: DEFINITION_PATH_PREFIX, + }); expect(wrapper.find({ ref: 'code-output' }).exists()).toBe(false); expect(wrapper.find({ ref: 'doc-output' }).exists()).toBe(true); diff --git a/spec/frontend/code_navigation/store/actions_spec.js b/spec/frontend/code_navigation/store/actions_spec.js index 6d2ede6dda7..3996e8ea1f5 100644 --- a/spec/frontend/code_navigation/store/actions_spec.js +++ b/spec/frontend/code_navigation/store/actions_spec.js @@ -173,7 +173,11 @@ describe('Code navigation actions', () => { [ { type: 'SET_CURRENT_DEFINITION', - payload: { definition: { hover: 'test' }, position: { height: 0, x: 0, y: 0 } }, + payload: { + blobPath: 'index.js', + definition: { hover: 'test' }, + position: { height: 0, x: 0, y: 0 }, + }, }, ], [], @@ -193,7 +197,11 @@ describe('Code navigation actions', () => { [ { type: 'SET_CURRENT_DEFINITION', - payload: { definition: { hover: 'test' }, position: { height: 0, x: 0, y: 0 } }, + payload: { + blobPath: 'index.js', + definition: { hover: 'test' }, + position: { height: 0, x: 0, y: 0 }, + }, }, ], [], @@ -214,7 +222,11 @@ describe('Code navigation actions', () => { [ { type: 'SET_CURRENT_DEFINITION', - payload: { definition: { hover: 'test' }, position: { height: 0, x: 0, y: 0 } }, + payload: { + blobPath: 'index.js', + definition: { hover: 'test' }, + position: { height: 0, x: 0, y: 0 }, + }, }, ], [], |