diff options
author | Phil Hughes <me@iamphill.com> | 2019-06-13 13:03:54 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-06-13 13:03:54 +0300 |
commit | 8d2ee368bdb1757a3620f6a05e3e435bea3c6ba2 (patch) | |
tree | 93360f53875cd25e63412c217852c3072356c506 /spec/frontend | |
parent | 738f55a0376f86a7e52fb4b76f3e22bd5da514c2 (diff) |
Click file row in repository Vue app to view file
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap | 1 | ||||
-rw-r--r-- | spec/frontend/repository/components/table/row_spec.js | 31 |
2 files changed, 31 insertions, 1 deletions
diff --git a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap index 86bfde1a28c..1f06d693411 100644 --- a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap +++ b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap @@ -15,6 +15,7 @@ exports[`Repository table row component renders table row 1`] = ` <a class="str-truncated" + href="https://test.com" > test 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', |