1108446974
* Feature: Move to the next conversation when I resolve a the current conversation * check if nextId is present before emitting the event * use es6 string literals * use a named variable for better reading * create a variable for better readability * better sintax to get clickable element * after last, go to first chat when resolve * use state and action to set next chat * remove not used emit * clear selected state when there is not next chat * Remove deprecated scope from FB Channel (#761) Remove deprecated scope from FB Channel * Feature: Customise the position of messenger (#767) Co-authored-by: Nithin David Thomas <webofnithin@gmail.com> * Bug: Redirect user to set new password screen (#772) * auto linter * fix js linter * sort chats on getter / filter before getting next chat * Revert not related changes on ConversationCard.vue * add test for getNextChatConversation getter * remove not used module * add test for getAllConversations getter
83 lines
1.7 KiB
JavaScript
83 lines
1.7 KiB
JavaScript
import commonHelpers from '../../../../helper/commons';
|
|
import getters from '../../conversations/getters';
|
|
|
|
// loads .last() helper
|
|
commonHelpers();
|
|
|
|
describe('#getters', () => {
|
|
describe('#getAllConversations', () => {
|
|
it('order conversations based on last message date', () => {
|
|
const state = {
|
|
allConversations: [
|
|
{
|
|
id: 1,
|
|
messages: [
|
|
{
|
|
created_at: 1466424480,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: 2,
|
|
messages: [
|
|
{
|
|
created_at: 2466424490,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
expect(getters.getAllConversations(state)).toEqual([
|
|
{
|
|
id: 2,
|
|
messages: [
|
|
{
|
|
created_at: 2466424490,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: 1,
|
|
messages: [
|
|
{
|
|
created_at: 1466424480,
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
describe('#getNextChatConversation', () => {
|
|
it('return the next chat', () => {
|
|
const state = {
|
|
allConversations: [
|
|
{
|
|
id: 1,
|
|
},
|
|
{
|
|
id: 2,
|
|
},
|
|
],
|
|
selectedChat: {
|
|
id: 1,
|
|
},
|
|
};
|
|
expect(getters.getNextChatConversation(state)).toEqual({
|
|
id: 2,
|
|
});
|
|
});
|
|
it('return null when there is only one chat', () => {
|
|
const state = {
|
|
allConversations: [
|
|
{
|
|
id: 1,
|
|
},
|
|
],
|
|
selectedChat: {
|
|
id: 1,
|
|
},
|
|
};
|
|
expect(getters.getNextChatConversation(state)).toBeNull();
|
|
});
|
|
});
|
|
});
|