Chore: Remove selectedChat from store (#1087)

* Chore: Remove selected chat from store
This commit is contained in:
Pranav Raj S
2020-07-23 23:33:17 +05:30
committed by GitHub
parent e72f29a26e
commit c7d962b20f
7 changed files with 76 additions and 84 deletions

View File

@@ -58,9 +58,7 @@ describe('#getters', () => {
id: 2,
},
],
selectedChat: {
id: 1,
},
selectedChatId: 1,
};
expect(getters.getNextChatConversation(state)).toEqual({
id: 2,
@@ -73,9 +71,7 @@ describe('#getters', () => {
id: 1,
},
],
selectedChat: {
id: 1,
},
selectedChatId: 1,
};
expect(getters.getNextChatConversation(state)).toBeNull();
});

View File

@@ -0,0 +1,46 @@
import types from '../../../mutation-types';
import { mutations } from '../../conversations';
describe('#mutations', () => {
describe('#EMPTY_ALL_CONVERSATION', () => {
it('empty conversations', () => {
const state = { allConversations: [{ id: 1 }], selectedChatId: 1 };
mutations[types.EMPTY_ALL_CONVERSATION](state);
expect(state.allConversations).toEqual([]);
expect(state.selectedChatId).toEqual(null);
});
});
describe('#MARK_MESSAGE_READ', () => {
it('mark conversation as read', () => {
const state = { allConversations: [{ id: 1 }] };
const lastSeen = new Date().getTime() / 1000;
mutations[types.MARK_MESSAGE_READ](state, { id: 1, lastSeen });
expect(state.allConversations).toEqual([
{ id: 1, agent_last_seen_at: lastSeen },
]);
});
});
describe('#CLEAR_CURRENT_CHAT_WINDOW', () => {
it('clears current chat window', () => {
const state = { selectedChatId: 1 };
mutations[types.CLEAR_CURRENT_CHAT_WINDOW](state);
expect(state.selectedChatId).toEqual(null);
});
});
describe('#SET_CURRENT_CHAT_WINDOW', () => {
it('set current chat window', () => {
const state = { selectedChatId: 1 };
mutations[types.SET_CURRENT_CHAT_WINDOW](state, { id: 2 });
expect(state.selectedChatId).toEqual(2);
});
it('does not set current chat window', () => {
const state = { selectedChatId: 1 };
mutations[types.SET_CURRENT_CHAT_WINDOW](state);
expect(state.selectedChatId).toEqual(1);
});
});
});