Chatwoot/app/javascript/dashboard/mixins/specs/conversaton.spec.js
Fayaz Ahmed 2b2252b66e
feat: Add a read indicator for web-widget channel (#4224)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2022-04-20 16:03:12 +05:30

36 lines
1.3 KiB
JavaScript

import conversationMixin from '../conversations';
import conversationFixture from './conversationFixtures';
import commonHelpers from '../../helper/commons';
commonHelpers();
describe('#conversationMixin', () => {
it('should return unread message count 2 if conversation is passed', () => {
expect(
conversationMixin.methods.unreadMessagesCount(
conversationFixture.conversation
)
).toEqual(2);
});
it('should return last message if conversation is passed', () => {
expect(
conversationMixin.methods.lastMessage(conversationFixture.conversation)
).toEqual(conversationFixture.lastMessage);
});
it('should return read messages if conversation is passed', () => {
expect(
conversationMixin.methods.readMessages(conversationFixture.conversation)
).toEqual(conversationFixture.readMessages);
});
it('should return read messages if conversation is passed', () => {
expect(
conversationMixin.methods.unReadMessages(conversationFixture.conversation)
).toEqual(conversationFixture.unReadMessages);
});
it('should return the user message read flag', () => {
const contactLastSeen = 1649856659;
const createdAt = 1649859419;
expect(
conversationMixin.methods.hasUserReadMessage(createdAt, contactLastSeen)
).toEqual(false);
});
});