mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
feat(messenger): offlineDelivered flag on thread chat
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { MessengerThreadChat } from './MessengerThreadChat';
|
||||||
|
|
||||||
|
describe('MessengerThreadChat.offlineDelivered', () =>
|
||||||
|
{
|
||||||
|
it('is true for a CHAT message with extraData "offline"', () =>
|
||||||
|
{
|
||||||
|
const chat = new MessengerThreadChat(5, 'hello', 60, 'offline', MessengerThreadChat.CHAT);
|
||||||
|
expect(chat.offlineDelivered).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is false for a normal CHAT message with no extraData', () =>
|
||||||
|
{
|
||||||
|
const chat = new MessengerThreadChat(5, 'hello', 0, null, MessengerThreadChat.CHAT);
|
||||||
|
expect(chat.offlineDelivered).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is false when extraData is some other value (e.g. group chat data)', () =>
|
||||||
|
{
|
||||||
|
const chat = new MessengerThreadChat(5, 'hi', 0, 'Bob/figurestr/5', MessengerThreadChat.CHAT);
|
||||||
|
expect(chat.offlineDelivered).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is false for a non-CHAT type even if extraData is "offline"', () =>
|
||||||
|
{
|
||||||
|
const chat = new MessengerThreadChat(5, 'hi', 0, 'offline', MessengerThreadChat.ROOM_INVITE);
|
||||||
|
expect(chat.offlineDelivered).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -74,6 +74,11 @@ export class MessengerThreadChat
|
|||||||
return this._extraData;
|
return this._extraData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get offlineDelivered(): boolean
|
||||||
|
{
|
||||||
|
return (this._type === MessengerThreadChat.CHAT) && (this._extraData === 'offline');
|
||||||
|
}
|
||||||
|
|
||||||
public get date(): Date
|
public get date(): Date
|
||||||
{
|
{
|
||||||
return this._date;
|
return this._date;
|
||||||
|
|||||||
Reference in New Issue
Block a user