test: new inReplyTo states

This commit is contained in:
Shivam Mishra
2023-10-04 18:14:15 +05:30
parent 249fcdf471
commit a862ddfafe
3 changed files with 94 additions and 0 deletions
@@ -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,
},
],
]);
});
});
});
@@ -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();
});
});
});
@@ -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 = {