salix/back/methods/notification/specs/send.spec.js

34 lines
889 B
JavaScript
Raw Normal View History

const models = require('vn-loopback/server/server').models;
2022-07-25 06:25:46 +00:00
describe('Notification Send()', () => {
it('should send notification', async() => {
const statusPending = 'pending';
const tx = await models.NotificationQueue.beginTransaction({});
const options = {transaction: tx};
const filter = {
where: {
status: statusPending
}
};
let before;
let after;
try {
before = await models.NotificationQueue.find(filter, options);
await models.Notification.send(options);
after = await models.NotificationQueue.find(filter, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(before.length).toEqual(3);
expect(after.length).toEqual(0);
});
});