2024-11-11 07:06:22 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
|
|
|
describe('sendMail', () => {
|
|
|
|
it('should insert in mail', async() => {
|
2024-11-11 07:12:07 +00:00
|
|
|
const tx = await models.Sale.beginTransaction({});
|
|
|
|
const options = {transaction: tx};
|
|
|
|
options.transaction = tx;
|
|
|
|
let mailCountBefore;
|
|
|
|
let mailCountAfter;
|
2024-11-11 07:06:22 +00:00
|
|
|
const ctx = {
|
|
|
|
req: {accessToken: {userId: 50}},
|
|
|
|
args: {workerFk: 1106, year: 2001, week: 1}
|
|
|
|
};
|
|
|
|
|
2024-11-11 07:12:07 +00:00
|
|
|
try {
|
|
|
|
mailCountBefore = await models.Mail.count(options);
|
|
|
|
await models.WorkerTimeControl.sendMail(ctx, options);
|
|
|
|
mailCountAfter = await models.Mail.count(options);
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
2024-11-11 07:06:22 +00:00
|
|
|
|
|
|
|
expect(mailCountAfter).toBeGreaterThan(mailCountBefore);
|
|
|
|
await tx.rollback();
|
|
|
|
});
|
|
|
|
});
|