diff options
Diffstat (limited to 'spec/frontend/code_navigation/components/popover_spec.js')
-rw-r--r-- | spec/frontend/code_navigation/components/popover_spec.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/frontend/code_navigation/components/popover_spec.js b/spec/frontend/code_navigation/components/popover_spec.js index d5a72ab8af8..7b323cfab72 100644 --- a/spec/frontend/code_navigation/components/popover_spec.js +++ b/spec/frontend/code_navigation/components/popover_spec.js @@ -40,6 +40,17 @@ const MOCK_DOCS_DATA = Object.freeze({ definition_path: 'test.js#L20', }); +const MOCK_DATA_WITH_REFERENCES = Object.freeze({ + hover: [ + { + language: null, + value: 'console.log', + }, + ], + references: [{ path: 'index.js' }, { path: 'app.js' }], + definition_path: 'test.js#L20', +}); + let wrapper; function factory({ position, data, definitionPathPrefix, blobPath = 'index.js' }) { @@ -64,6 +75,16 @@ describe('Code navigation popover component', () => { expect(wrapper.element).toMatchSnapshot(); }); + it('srender references tab with empty text when no references exist', () => { + factory({ + position: { x: 0, y: 0, height: 0 }, + data: MOCK_CODE_DATA, + definitionPathPrefix: DEFINITION_PATH_PREFIX, + }); + + expect(wrapper.find('[data-testid="references-tab"]').text()).toContain('No references found'); + }); + it('renders link with hash to current file', () => { factory({ position: { x: 0, y: 0, height: 0 }, @@ -75,6 +96,17 @@ describe('Code navigation popover component', () => { expect(wrapper.find('[data-testid="go-to-definition-btn"]').attributes('href')).toBe('#L20'); }); + it('renders list of references', () => { + factory({ + position: { x: 0, y: 0, height: 0 }, + data: MOCK_DATA_WITH_REFERENCES, + definitionPathPrefix: DEFINITION_PATH_PREFIX, + }); + + expect(wrapper.find('[data-testid="references-tab"]').exists()).toBe(true); + expect(wrapper.findAll('[data-testid="reference-link"]').length).toBe(2); + }); + describe('code output', () => { it('renders code output', () => { factory({ |