2022-07-25 06:25:10 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
2022-07-25 06:25:46 +00:00
|
|
|
describe('Notification Send()', () => {
|
2022-07-25 06:25:10 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-10-14 11:22:53 +00:00
|
|
|
expect(before.length).toEqual(3);
|
2022-07-25 06:25:10 +00:00
|
|
|
expect(after.length).toEqual(0);
|
|
|
|
});
|
|
|
|
});
|