diff options
Diffstat (limited to 'spec/javascripts/notes/stores/mutation_spec.js')
-rw-r--r-- | spec/javascripts/notes/stores/mutation_spec.js | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/spec/javascripts/notes/stores/mutation_spec.js b/spec/javascripts/notes/stores/mutation_spec.js index a15ff1a5888..6b7f61468d5 100644 --- a/spec/javascripts/notes/stores/mutation_spec.js +++ b/spec/javascripts/notes/stores/mutation_spec.js @@ -1,3 +1,4 @@ +import Vue from 'vue'; import mutations from '~/notes/stores/mutations'; import { note, @@ -333,7 +334,7 @@ describe('Notes Store mutations', () => { }); }); - describe('SET_NOTES_FETCHING_STATE', () => { + describe('SET_NOTES_FETCHED_STATE', () => { it('should set the given state', () => { const state = { isNotesFetched: false, @@ -343,4 +344,37 @@ describe('Notes Store mutations', () => { expect(state.isNotesFetched).toEqual(true); }); }); + + describe('SET_DISCUSSION_DIFF_LINES', () => { + it('sets truncated_diff_lines', () => { + const state = { + discussions: [ + { + id: 1, + }, + ], + }; + + mutations.SET_DISCUSSION_DIFF_LINES(state, { discussionId: 1, diffLines: ['test'] }); + + expect(state.discussions[0].truncated_diff_lines).toEqual(['test']); + }); + + it('keeps reactivity of discussion', () => { + const state = {}; + Vue.set(state, 'discussions', [ + { + id: 1, + expanded: false, + }, + ]); + const discussion = state.discussions[0]; + + mutations.SET_DISCUSSION_DIFF_LINES(state, { discussionId: 1, diffLines: ['test'] }); + + discussion.expanded = true; + + expect(state.discussions[0].expanded).toBe(true); + }); + }); }); |