diff options
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/notes/stores/getters_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/notes/stores/mutation_spec.js | 24 |
2 files changed, 28 insertions, 4 deletions
diff --git a/spec/frontend/notes/stores/getters_spec.js b/spec/frontend/notes/stores/getters_spec.js index 1ade9464128..602e4c70741 100644 --- a/spec/frontend/notes/stores/getters_spec.js +++ b/spec/frontend/notes/stores/getters_spec.js @@ -35,7 +35,7 @@ describe('Getters Notes Store', () => { notesData: notesDataMock, userData: userDataMock, noteableData: noteableDataMock, - descriptionVersion: 'descriptionVersion', + descriptionVersions: 'descriptionVersions', }; }); @@ -387,9 +387,9 @@ describe('Getters Notes Store', () => { }); }); - describe('descriptionVersion', () => { - it('should return `descriptionVersion`', () => { - expect(getters.descriptionVersion(state)).toEqual('descriptionVersion'); + describe('descriptionVersions', () => { + it('should return `descriptionVersions`', () => { + expect(getters.descriptionVersions(state)).toEqual('descriptionVersions'); }); }); }); diff --git a/spec/frontend/notes/stores/mutation_spec.js b/spec/frontend/notes/stores/mutation_spec.js index 46b4081f6f6..ee772afbc03 100644 --- a/spec/frontend/notes/stores/mutation_spec.js +++ b/spec/frontend/notes/stores/mutation_spec.js @@ -8,6 +8,7 @@ import { userDataMock, noteableDataMock, individualNote, + notesWithDescriptionChanges, } from '../mock_data'; const RESOLVED_NOTE = { resolvable: true, resolved: true }; @@ -579,4 +580,27 @@ describe('Notes Store mutations', () => { expect(state.convertedDisscussionIds).not.toContain(discussion.id); }); }); + + describe('RECEIVE_DESCRIPTION_VERSION', () => { + const descriptionVersion = notesWithDescriptionChanges[0].notes[0].note; + const versionId = notesWithDescriptionChanges[0].notes[0].id; + const state = {}; + + it('adds a descriptionVersion', () => { + mutations.RECEIVE_DESCRIPTION_VERSION(state, { descriptionVersion, versionId }); + expect(state.descriptionVersions[versionId]).toBe(descriptionVersion); + }); + }); + + describe('RECEIVE_DELETE_DESCRIPTION_VERSION', () => { + const descriptionVersion = notesWithDescriptionChanges[0].notes[0].note; + const versionId = notesWithDescriptionChanges[0].notes[0].id; + const state = { descriptionVersions: { [versionId]: descriptionVersion } }; + const deleted = 'Deleted'; + + it('updates descriptionVersion to "Deleted"', () => { + mutations.RECEIVE_DELETE_DESCRIPTION_VERSION(state, { [versionId]: deleted }); + expect(state.descriptionVersions[versionId]).toBe(deleted); + }); + }); }); |