34 lines
889 B
JavaScript
34 lines
889 B
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
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);
|
|
});
|
|
});
|