salix/back/methods/chat/spec/sendQueued.spec.js

42 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

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,
2023-03-21 10:37:26 +00:00
status: 'pending',
2022-06-03 11:36:21 +00:00
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,
2023-03-21 10:37:26 +00:00
status: 'pending',
2022-06-03 11:36:21 +00:00
attempts: 0
};
await chatModel.destroyAll();
await chatModel.create(chat);
await chatModel.sendQueued();
expect(chatModel.sendMessage).toHaveBeenCalled();
});
});