diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-03 18:10:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-03 18:10:01 +0300 |
commit | 4f41b713eb264096903c168375815adec96ab8ac (patch) | |
tree | 48f4ccefb4e6521c02c4101e84db65025efacfbe /spec/frontend/repository | |
parent | f5987db869d7025fb8f403edc5106c5f2a3e448f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/repository')
-rw-r--r-- | spec/frontend/repository/components/blob_content_viewer_spec.js | 18 | ||||
-rw-r--r-- | spec/frontend/repository/components/blob_header_edit_spec.js | 63 |
2 files changed, 78 insertions, 3 deletions
diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js index f03df8cf2ac..ea554db6909 100644 --- a/spec/frontend/repository/components/blob_content_viewer_spec.js +++ b/spec/frontend/repository/components/blob_content_viewer_spec.js @@ -162,15 +162,22 @@ describe('Blob content viewer component', () => { }); describe('BlobHeader action slot', () => { - it('renders BlobHeaderEdit button in simple viewer', async () => { + const { ideEditPath, editBlobPath } = simpleMockData; + + it('renders BlobHeaderEdit buttons in simple viewer', async () => { fullFactory({ mockData: { blobInfo: simpleMockData }, stubs: { BlobContent: true, }, }); + await nextTick(); - expect(findBlobHeaderEdit().props('editPath')).toEqual('some_file.js/edit'); + + expect(findBlobHeaderEdit().props()).toMatchObject({ + editPath: editBlobPath, + webIdePath: ideEditPath, + }); }); it('renders BlobHeaderEdit button in rich viewer', async () => { @@ -180,8 +187,13 @@ describe('Blob content viewer component', () => { BlobContent: true, }, }); + await nextTick(); - expect(findBlobHeaderEdit().props('editPath')).toEqual('some_file.js/edit'); + + expect(findBlobHeaderEdit().props()).toMatchObject({ + editPath: editBlobPath, + webIdePath: ideEditPath, + }); }); }); }); diff --git a/spec/frontend/repository/components/blob_header_edit_spec.js b/spec/frontend/repository/components/blob_header_edit_spec.js new file mode 100644 index 00000000000..bd02bbe65d9 --- /dev/null +++ b/spec/frontend/repository/components/blob_header_edit_spec.js @@ -0,0 +1,63 @@ +import { GlButton } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import BlobHeaderEdit from '~/repository/components/blob_header_edit.vue'; + +const DEFAULT_PROPS = { + editPath: 'some_file.js/edit', + webIdePath: 'some_file.js/ide/edit', +}; + +describe('BlobHeaderEdit component', () => { + let wrapper; + + const createComponent = (props = {}) => { + wrapper = shallowMount(BlobHeaderEdit, { + propsData: { + ...DEFAULT_PROPS, + ...props, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + const findButtons = () => wrapper.findAll(GlButton); + const findEditButton = () => findButtons().at(0); + const findWebIdeButton = () => findButtons().at(1); + + it('renders component', () => { + createComponent(); + + const { editPath, webIdePath } = DEFAULT_PROPS; + + expect(wrapper.props()).toMatchObject({ + editPath, + webIdePath, + }); + }); + + it('renders both buttons', () => { + createComponent(); + + expect(findButtons()).toHaveLength(2); + }); + + it('renders the Edit button', () => { + createComponent(); + + expect(findEditButton().attributes('href')).toBe(DEFAULT_PROPS.editPath); + expect(findEditButton().text()).toBe('Edit'); + expect(findEditButton()).not.toBeDisabled(); + }); + + it('renders the Web IDE button', () => { + createComponent(); + + expect(findWebIdeButton().attributes('href')).toBe(DEFAULT_PROPS.webIdePath); + expect(findWebIdeButton().text()).toBe('Web IDE'); + expect(findWebIdeButton()).not.toBeDisabled(); + }); +}); |