Merge pull request '7743-simpleTestForSendMail' (!3170) from 7743-simpleTestForSendMail into dev
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-dev This commit looks good Details

Reviewed-on: #3170
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Pablo Natek 2024-11-15 11:54:23 +00:00
commit 55daa2d02b
2 changed files with 27 additions and 1 deletions

View File

@ -1,5 +1,4 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const UserError = require('vn-loopback/util/user-error');
describe('workerTimeControl login()', () => {

View File

@ -0,0 +1,27 @@
const models = require('vn-loopback/server/server').models;
describe('sendMail', () => {
it('should insert in mail', async() => {
const tx = await models.Sale.beginTransaction({});
const options = {transaction: tx};
options.transaction = tx;
let mailCountBefore;
let mailCountAfter;
const ctx = {
req: {accessToken: {userId: 50}},
args: {workerFk: 1106, year: 2001, week: 1}
};
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;
}
expect(mailCountAfter).toBeGreaterThan(mailCountBefore);
await tx.rollback();
});
});