diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-28 09:10:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-28 09:10:17 +0300 |
commit | d3eb1e90a58fc97c9c1548e8ac9631c233e723ea (patch) | |
tree | 0be332ab901bd95225437ffd332bc83c30c99742 /spec/frontend/notes | |
parent | 6078d7becc4a0d70aafc4a3934a70b8cf2b3775e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/notes')
-rw-r--r-- | spec/frontend/notes/components/note_edited_text_spec.js | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/spec/frontend/notes/components/note_edited_text_spec.js b/spec/frontend/notes/components/note_edited_text_spec.js index 0a5fe48ef94..e76a1de0a66 100644 --- a/spec/frontend/notes/components/note_edited_text_spec.js +++ b/spec/frontend/notes/components/note_edited_text_spec.js @@ -1,3 +1,4 @@ +import { GlSprintf, GlLink } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import NoteEditedText from '~/notes/components/note_edited_text.vue'; @@ -5,41 +6,67 @@ const propsData = { actionText: 'Edited', className: 'foo-bar', editedAt: '2017-08-04T09:52:31.062Z', - editedBy: { - avatar_url: 'path', - id: 1, - name: 'Root', - path: '/root', - state: 'active', - username: 'root', - }, + editedBy: null, }; describe('NoteEditedText', () => { let wrapper; - beforeEach(() => { + const createWrapper = (props = {}) => { wrapper = shallowMount(NoteEditedText, { - propsData, + propsData: { + ...propsData, + ...props, + }, + stubs: { + GlSprintf, + }, }); - }); + }; + + const findUserElement = () => wrapper.findComponent(GlLink); afterEach(() => { wrapper.destroy(); }); - it('should render block with provided className', () => { - expect(wrapper.classes()).toContain(propsData.className); - }); + describe('default', () => { + beforeEach(() => { + createWrapper(); + }); - it('should render provided actionText', () => { - expect(wrapper.text().trim()).toContain(propsData.actionText); + it('should render block with provided className', () => { + expect(wrapper.classes()).toContain(propsData.className); + }); + + it('should render provided actionText', () => { + expect(wrapper.text().trim()).toContain(propsData.actionText); + }); + + it('should not render user information', () => { + expect(findUserElement().exists()).toBe(false); + }); }); - it('should render provided user information', () => { - const authorLink = wrapper.find('.js-user-link'); + describe('edited note', () => { + const editedBy = { + avatar_url: 'path', + id: 1, + name: 'Root', + path: '/root', + state: 'active', + username: 'root', + }; + + beforeEach(() => { + createWrapper({ editedBy }); + }); + + it('should render user information', () => { + const authorLink = findUserElement(); - expect(authorLink.attributes('href')).toEqual(propsData.editedBy.path); - expect(authorLink.text().trim()).toEqual(propsData.editedBy.name); + expect(authorLink.attributes('href')).toEqual(editedBy.path); + expect(authorLink.text().trim()).toEqual(editedBy.name); + }); }); }); |