8144-devToTest_2448 #3216
|
@ -1,5 +1,4 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
describe('workerTimeControl login()', () => {
|
describe('workerTimeControl login()', () => {
|
||||||
|
|
|
@ -2,17 +2,24 @@ const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('sendMail', () => {
|
describe('sendMail', () => {
|
||||||
it('should insert in mail', async() => {
|
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 = {
|
const ctx = {
|
||||||
req: {accessToken: {userId: 50}},
|
req: {accessToken: {userId: 50}},
|
||||||
args: {workerFk: 1106, year: 2001, week: 1}
|
args: {workerFk: 1106, year: 2001, week: 1}
|
||||||
};
|
};
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
options.transaction = tx;
|
|
||||||
|
|
||||||
const mailCountBefore = await models.Mail.count(options);
|
try {
|
||||||
|
mailCountBefore = await models.Mail.count(options);
|
||||||
await models.WorkerTimeControl.sendMail(ctx, options);
|
await models.WorkerTimeControl.sendMail(ctx, options);
|
||||||
const mailCountAfter = await models.Mail.count(options);
|
mailCountAfter = await models.Mail.count(options);
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
expect(mailCountAfter).toBeGreaterThan(mailCountBefore);
|
expect(mailCountAfter).toBeGreaterThan(mailCountBefore);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
Loading…
Reference in New Issue