diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-02-25 19:38:29 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-02-25 19:38:29 +0300 |
commit | a26cd1235a6eda5fc32fb4fba2f32489536096e5 (patch) | |
tree | fe9392cc965315c22039b44dde720a6c9112e437 /spec | |
parent | 15528c75549cc1be6cb0201556ea591953279e84 (diff) |
Extract ResolveWithIssueButton from NoteableDiscussion component
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/notes/components/discussion_resolve_with_issue_button_spec.js | 31 | ||||
-rw-r--r-- | spec/javascripts/notes/components/noteable_discussion_spec.js | 39 |
2 files changed, 70 insertions, 0 deletions
diff --git a/spec/javascripts/notes/components/discussion_resolve_with_issue_button_spec.js b/spec/javascripts/notes/components/discussion_resolve_with_issue_button_spec.js new file mode 100644 index 00000000000..b2a91c9919a --- /dev/null +++ b/spec/javascripts/notes/components/discussion_resolve_with_issue_button_spec.js @@ -0,0 +1,31 @@ +import { GlButton } from '@gitlab/ui'; +import ResolveWithIssueButton from '~/notes/components/discussion_resolve_with_issue_button.vue'; +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { TEST_HOST } from 'spec/test_constants'; + +const localVue = createLocalVue(); + +describe('ResolveWithIssueButton', () => { + let wrapper; + const url = `${TEST_HOST}/hello-world/`; + + beforeEach(() => { + wrapper = shallowMount(ResolveWithIssueButton, { + localVue, + sync: false, + propsData: { + url, + }, + }); + }); + + afterEach(() => { + wrapper.destroy(); + }); + + it('it should have a link with the provided link property as href', () => { + const button = wrapper.find(GlButton); + + expect(button.attributes().href).toBe(url); + }); +}); diff --git a/spec/javascripts/notes/components/noteable_discussion_spec.js b/spec/javascripts/notes/components/noteable_discussion_spec.js index 2eae22e095f..2b93fb9fb45 100644 --- a/spec/javascripts/notes/components/noteable_discussion_spec.js +++ b/spec/javascripts/notes/components/noteable_discussion_spec.js @@ -2,6 +2,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import createStore from '~/notes/stores'; import noteableDiscussion from '~/notes/components/noteable_discussion.vue'; import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue'; +import ResolveWithIssueButton from '~/notes/components/discussion_resolve_with_issue_button.vue'; import '~/behaviors/markdown/render_gfm'; import { noteableDataMock, discussionMock, notesDataMock } from '../mock_data'; import mockDiffFile from '../../diffs/mock_data/diff_file'; @@ -238,4 +239,42 @@ describe('noteable_discussion component', () => { }); }); }); + + describe('for resolved discussion', () => { + beforeEach(() => { + const discussion = getJSONFixture(discussionWithTwoUnresolvedNotes)[0]; + wrapper.setProps({ discussion }); + }); + + it('does not display a button to resolve with issue', () => { + const button = wrapper.find(ResolveWithIssueButton); + + expect(button.exists()).toBe(false); + }); + }); + + describe('for unresolved discussion', () => { + beforeEach(done => { + const discussion = { + ...getJSONFixture(discussionWithTwoUnresolvedNotes)[0], + expanded: true, + }; + discussion.notes = discussion.notes.map(note => ({ + ...note, + resolved: false, + })); + + wrapper.setProps({ discussion }); + wrapper.vm + .$nextTick() + .then(done) + .catch(done.fail); + }); + + it('displays a button to resolve with issue', () => { + const button = wrapper.find(ResolveWithIssueButton); + + expect(button.exists()).toBe(true); + }); + }); }); |