2022-06-03 11:36:21 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
|
|
|
describe('Chat sendCheckingPresence()', () => {
|
2023-01-16 14:18:24 +00:00
|
|
|
const today = Date.vnNew();
|
2022-06-03 11:36:21 +00:00
|
|
|
today.setHours(6, 0);
|
|
|
|
const chatModel = models.Chat;
|
|
|
|
|
|
|
|
it(`should call to sendCheckingUserStatus()`, async() => {
|
|
|
|
spyOn(chatModel, 'sendCheckingUserStatus').and.callThrough();
|
|
|
|
|
|
|
|
const chat = {
|
|
|
|
checkUserStatus: 1,
|
|
|
|
status: 0,
|
|
|
|
attempts: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
await chatModel.destroyAll();
|
|
|
|
await chatModel.create(chat);
|
|
|
|
|
|
|
|
await chatModel.sendQueued();
|
|
|
|
|
|
|
|
expect(chatModel.sendCheckingUserStatus).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should call to sendMessage() method`, async() => {
|
|
|
|
spyOn(chatModel, 'sendMessage').and.callThrough();
|
|
|
|
|
|
|
|
const chat = {
|
|
|
|
checkUserStatus: 0,
|
|
|
|
status: 0,
|
|
|
|
attempts: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
await chatModel.destroyAll();
|
|
|
|
await chatModel.create(chat);
|
|
|
|
|
|
|
|
await chatModel.sendQueued();
|
|
|
|
|
|
|
|
expect(chatModel.sendMessage).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|