42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
|
const models = require('vn-loopback/server/server').models;
|
||
|
|
||
|
describe('Chat sendCheckingPresence()', () => {
|
||
|
const today = new Date();
|
||
|
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();
|
||
|
});
|
||
|
});
|