diff options
| author | Filipa Lacerda <filipa@gitlab.com> | 2017-08-11 16:52:29 +0100 |
|---|---|---|
| committer | Filipa Lacerda <filipa@gitlab.com> | 2017-08-11 19:54:58 +0100 |
| commit | cf77cdba51059cd3ae99a66b7bf103cd0bde1171 (patch) | |
| tree | f79cfe6a0d014c0cf3451b1f8220b90c9563e957 /spec/javascripts/notes | |
| parent | 3e92f44ff223c9252f7726dcad46a3cb46298001 (diff) | |
| download | gitlab-ce-cf77cdba51059cd3ae99a66b7bf103cd0bde1171.tar.gz | |
Adds unit tests for discussion component
Diffstat (limited to 'spec/javascripts/notes')
| -rw-r--r-- | spec/javascripts/notes/components/issue_discussion_spec.js | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/spec/javascripts/notes/components/issue_discussion_spec.js b/spec/javascripts/notes/components/issue_discussion_spec.js index cb29b4176ad..05c6b57f93e 100644 --- a/spec/javascripts/notes/components/issue_discussion_spec.js +++ b/spec/javascripts/notes/components/issue_discussion_spec.js @@ -1,42 +1,49 @@ +import Vue from 'vue'; +import store from '~/notes/stores'; +import issueDiscussion from '~/notes/components/issue_discussion.vue'; +import { issueDataMock, discussionMock, notesDataMock } from '../mock_data'; describe('issue_discussion component', () => { - it('should render user avatar', () => { - }); - - it('should render discussion header', () => { + let vm; - }); + beforeEach(() => { + const Component = Vue.extend(issueDiscussion); - describe('updated note', () => { - it('should show information about update', () => { + store.dispatch('setIssueData', issueDataMock); + store.dispatch('setNotesData', notesDataMock); - }); + vm = new Component({ + store, + propsData: { + note: discussionMock, + }, + }).$mount(); }); - describe('with open discussion', () => { - it('should render system note', () => { - - }); - - it('should render placeholder note', () => { + afterEach(() => { + vm.$destroy(); + }); - }); + it('should render user avatar', () => { + expect(vm.$el.querySelector('.user-avatar-link')).toBeDefined(); + }); - it('should render regular note', () => { + it('should render discussion header', () => { + expect(vm.$el.querySelector('.discussion-header')).toBeDefined(); + expect(vm.$el.querySelectorAll('.notes li').length).toEqual(discussionMock.notes.length); + }); + describe('actions', () => { + it('should render reply button', () => { + expect(vm.$el.querySelector('.js-vue-discussion-reply').textContent.trim()).toEqual('Reply...'); }); - describe('actions', () => { - it('should render reply button', () => { - - }); - - it('should toggle reply form', () => { - - }); - - it('should render signout widget when user is logged out', () => { - + it('should toggle reply form', (done) => { + vm.$el.querySelector('.js-vue-discussion-reply').click(); + Vue.nextTick(() => { + expect(vm.$refs.noteForm).toBeDefined(); + expect(vm.isReplying).toEqual(true); + done(); }); }); }); |
