From a862ddfafe2d8e8d16e6905152de6d0b15203fe2 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 4 Oct 2023 18:12:53 +0530 Subject: [PATCH] test: new inReplyTo states --- .../specs/draftMessages/actions.spec.js | 45 +++++++++++++++++++ .../specs/draftMessages/getters.spec.js | 20 +++++++++ .../specs/draftMessages/mutations.spec.js | 29 ++++++++++++ 3 files changed, 94 insertions(+) diff --git a/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js b/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js index 6260c6cef..9a08fab29 100644 --- a/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js +++ b/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js @@ -73,4 +73,49 @@ describe('#actions', () => { ]); }); }); + + describe('#setInReplyTo', () => { + it('sends correct actions', async () => { + await actions.setInReplyTo( + { + commit, + state: { + inReplyTo: {}, + }, + }, + { key: 45534, inReplyTo: 24332 } + ); + expect(commit.mock.calls).toEqual([ + [ + types.SET_IN_REPLY_TO, + { + key: 45534, + inReplyTo: 24332, + }, + ], + ]); + }); + }); + + describe('#deleteInReplyTo', () => { + it('sends correct actions', async () => { + await actions.deleteInReplyTo( + { + commit, + state: { + inReplyTo: {}, + }, + }, + { key: 45534 } + ); + expect(commit.mock.calls).toEqual([ + [ + types.REMOVE_IN_REPLY_TO, + { + key: 45534, + }, + ], + ]); + }); + }); }); diff --git a/app/javascript/dashboard/store/modules/specs/draftMessages/getters.spec.js b/app/javascript/dashboard/store/modules/specs/draftMessages/getters.spec.js index 899d1a74f..a6e250da0 100644 --- a/app/javascript/dashboard/store/modules/specs/draftMessages/getters.spec.js +++ b/app/javascript/dashboard/store/modules/specs/draftMessages/getters.spec.js @@ -22,4 +22,24 @@ describe('#getters', () => { }; expect(getters.getReplyEditorMode(state)).toEqual('reply'); }); + + describe('#getInReplyTo', () => { + it('returns the inReplyTo value if key is present', () => { + const state = { + inReplyTo: { + 1234: 9876, + }, + }; + expect(getters.getInReplyTo(state)(1234)).toEqual(9876); + }); + + it('returns undefined if key is not present', () => { + const state = { + inReplyTo: { + 1234: 9876, + }, + }; + expect(getters.getInReplyTo(state)('message-22')).toBeUndefined(); + }); + }); }); diff --git a/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js b/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js index f4695818b..cbc1055f1 100644 --- a/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js +++ b/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js @@ -31,6 +31,35 @@ describe('#mutations', () => { }); }); + describe('#SET_IN_REPLY_TO', () => { + it('sets the inReplyTo value', () => { + const state = { + inReplyTo: {}, + }; + mutations[types.SET_IN_REPLY_TO](state, { + key: 1234, + inReplyTo: 9876, + }); + expect(state.inReplyTo).toEqual({ + 1234: 9876, + }); + }); + }); + + describe('#REMOVE_IN_REPLY_TO', () => { + it('removes the inReplyTo value', () => { + const state = { + inReplyTo: { + 1234: 9876, + }, + }; + mutations[types.REMOVE_IN_REPLY_TO](state, { + key: 1234, + }); + expect(state.inReplyTo).toEqual({}); + }); + }); + describe('#SET_REPLY_EDITOR_MODE', () => { it('sets the reply editor mode', () => { const state = {