diff options
Diffstat (limited to 'spec/frontend/repository/components/table/row_spec.js')
-rw-r--r-- | spec/frontend/repository/components/table/row_spec.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index 90a502966ad..5a345ddeacd 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -1,7 +1,10 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils'; import { GlBadge } from '@gitlab/ui'; +import { visitUrl } from '~/lib/utils/url_utility'; import TableRow from '~/repository/components/table/row.vue'; +jest.mock('~/lib/utils/url_utility'); + let vm; let $router; @@ -11,7 +14,10 @@ function factory(propsData = {}) { }; vm = shallowMount(TableRow, { - propsData, + propsData: { + ...propsData, + url: `https://test.com`, + }, mocks: { $router, }, @@ -26,6 +32,7 @@ function factory(propsData = {}) { describe('Repository table row component', () => { afterEach(() => { vm.destroy(); + jest.clearAllMocks(); }); it('renders table row', () => { @@ -77,6 +84,28 @@ describe('Repository table row component', () => { } }); + it.each` + type | pushes + ${'tree'} | ${true} + ${'file'} | ${false} + ${'commit'} | ${false} + `('calls visitUrl if $type is not tree', ({ type, pushes }) => { + factory({ + id: '1', + path: 'test', + type, + currentPath: '/', + }); + + vm.trigger('click'); + + if (pushes) { + expect(visitUrl).not.toHaveBeenCalled(); + } else { + expect(visitUrl).toHaveBeenCalledWith('https://test.com'); + } + }); + it('renders commit ID for submodule', () => { factory({ id: '1', |