refactor: refs #6005 refactor spec

This commit is contained in:
Pablo Natek 2024-04-10 13:09:31 +02:00
parent 2a972a03ea
commit c581deef66
2 changed files with 9 additions and 33 deletions

View File

@ -1,38 +1,6 @@
const models = require('vn-loopback/server/server').models;
describe('Notification Send()', () => {
beforeAll(async() => {
await models.NotificationQueue.destroyAll();
await models.NotificationQueue.create(
[
{
id: 1,
params: '{"id": "1"}',
status: 'pending',
created: '2000-12-31T23:00:00.000Z',
notificationFk: 'print-email',
authorFk: 9
},
{
id: 2,
params: '{"id": "2"}',
status: 'pending',
created: '2000-12-31T23:00:00.000Z',
notificationFk: 'print-email',
authorFk: null
},
{
id: 3,
params: null,
status: 'pending',
created: '2000-12-31T23:00:00.000Z',
notificationFk: 'print-email',
authorFk: null
}
]
);
});
it('should send notification', async() => {
const statusPending = 'pending';
const tx = await models.NotificationQueue.beginTransaction({});

View File

@ -8,9 +8,17 @@ describe('Operator', () => {
const sentStatus = 'sent';
beforeEach(async() => {
await models.NotificationQueue.destroyAll({notificationFk: notificationName});
await deleteNotification();
});
afterAll(async() => {
await deleteNotification();
});
async function deleteNotification() {
await models.NotificationQueue.destroyAll({notificationFk: notificationName});
}
async function updateOperatorAndFindNotification(labelerFk = labeler) {
await models.Operator.updateAll({id: authorFk}, {workerFk: authorFk, labelerFk: labelerFk, sectorFk: sectorId});
return models.NotificationQueue.findOne({order: 'id DESC'});