From d9a3bbce61fc76aee6fb5cbc65e46e11af2affd0 Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Thu, 21 Sep 2017 03:08:17 +0300 Subject: IssueNotes: Resize comment form after note submit and discard. --- .../notes/components/issue_comment_form_spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/javascripts/notes') diff --git a/spec/javascripts/notes/components/issue_comment_form_spec.js b/spec/javascripts/notes/components/issue_comment_form_spec.js index cca5ec887a3..1c8b1b98242 100644 --- a/spec/javascripts/notes/components/issue_comment_form_spec.js +++ b/spec/javascripts/notes/components/issue_comment_form_spec.js @@ -1,4 +1,5 @@ import Vue from 'vue'; +import autosize from 'vendor/autosize'; import store from '~/notes/stores'; import issueCommentForm from '~/notes/components/issue_comment_form.vue'; import { loggedOutIssueData, notesDataMock, userDataMock, issueDataMock } from '../mock_data'; @@ -55,6 +56,19 @@ describe('issue_comment_form component', () => { expect(vm.$el.querySelector(`a[href="${quickActionsDocsPath}"]`).textContent.trim()).toEqual('quick actions'); }); + it('should resize textarea after note discarded', (done) => { + spyOn(autosize, 'update'); + spyOn(vm, 'discard').and.callThrough(); + + vm.note = 'foo'; + vm.discard(); + + Vue.nextTick(() => { + expect(autosize.update).toHaveBeenCalled(); + done(); + }); + }); + describe('edit mode', () => { it('should enter edit mode when arrow up is pressed', () => { spyOn(vm, 'editCurrentUserLastNote').and.callThrough(); -- cgit v1.2.1 From f22f75b752f741969484f4e2a49a7087b57b2df6 Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Fri, 22 Sep 2017 04:04:52 +0300 Subject: Fix rendering double note issue. --- spec/javascripts/notes/stores/actions_spec.js | 1 - spec/javascripts/notes/stores/mutation_spec.js | 30 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'spec/javascripts/notes') diff --git a/spec/javascripts/notes/stores/actions_spec.js b/spec/javascripts/notes/stores/actions_spec.js index 72d362acb2f..2b2219dcf0c 100644 --- a/spec/javascripts/notes/stores/actions_spec.js +++ b/spec/javascripts/notes/stores/actions_spec.js @@ -1,4 +1,3 @@ - import * as actions from '~/notes/stores/actions'; import testAction from './helpers'; import { discussionMock, notesDataMock, userDataMock, issueDataMock, individualNote } from '../mock_data'; diff --git a/spec/javascripts/notes/stores/mutation_spec.js b/spec/javascripts/notes/stores/mutation_spec.js index a38f29c1e39..1e22e03e178 100644 --- a/spec/javascripts/notes/stores/mutation_spec.js +++ b/spec/javascripts/notes/stores/mutation_spec.js @@ -3,19 +3,31 @@ import { note, discussionMock, notesDataMock, userDataMock, issueDataMock, indiv describe('Mutation Notes Store', () => { describe('ADD_NEW_NOTE', () => { - it('should add a new note to an array of notes', () => { - const state = { notes: [] }; + let state; + let noteData; + + beforeEach(() => { + state = { notes: [] }; + noteData = { + expanded: true, + id: note.discussion_id, + individual_note: true, + notes: [note], + reply_id: note.discussion_id, + }; mutations.ADD_NEW_NOTE(state, note); + }); + it('should add a new note to an array of notes', () => { expect(state).toEqual({ - notes: [{ - expanded: true, - id: note.discussion_id, - individual_note: true, - notes: [note], - reply_id: note.discussion_id, - }], + notes: [noteData], }); + expect(state.notes.length).toBe(1); + }); + + it('should not add the same note to the notes array', () => { + mutations.ADD_NEW_NOTE(state, note); + expect(state.notes.length).toBe(1); }); }); -- cgit v1.2.1