refs #6915 test_master24_8 #2067

Merged
alexm merged 561 commits from test_master24_8 into master 2024-02-22 07:31:34 +00:00
3 changed files with 50 additions and 29 deletions
Showing only changes of commit f2946e4168 - Show all commits

View File

@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models;
describe('route downloadCmrsZip()', () => {
beforeEach(() => {
spyOn(models.Route, 'downloadCmrsZip').and.returnValue([true]);
spyOn(models.Route, 'downloadCmrsZip').and.returnValue(true);
});
it('should create a zip file with the given cmr ids', async() => {
@ -17,13 +17,13 @@ describe('route downloadCmrsZip()', () => {
};
let cmrs = '1,2';
try {
await models.Route.downloadCmrsZip(ctx, cmrs);
const stream = await models.Route.downloadCmrsZip(ctx, cmrs);
expect(stream).toBeTrue();
await tx.rollback();
} catch (e) {
error = e;
await tx.rollback();
throw e;
}
expect(error).toBeDefined();
});
});

View File

@ -1,24 +0,0 @@
const models = require('vn-loopback/server/server').models;
describe('ticket saveCmr()', () => {
let ctx = {req: {
accessToken: {userId: 9}
}};
it(`should throw error if the cmr can't save`, async() => {
const tx = await models.Route.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const ticket = [1];
await models.Route.saveCmr(ctx, ticket, options);
await tx.rollback();
} catch (e) {
error = e;
await tx.rollback();
}
expect(error).toBeDefined();
});
});

View File

@ -0,0 +1,45 @@
const models = require('vn-loopback/server/server').models;
describe('ticket saveCmr()', () => {
beforeEach(() => {
spyOn(models.Ticket, 'saveCmr').and.returnValue(true);
});
it(`should throw error if the cmr can't save`, async() => {
const tx = await models.Ticket.beginTransaction({});
const ctx = {
req: {
getLocale: () => {
return 'en';
},
accessToken: {userId: 9}
},
args: {}
};
try {
const options = {transaction: tx};
const ticket = [1];
await models.Ticket.saveCmr(ctx, ticket);
const hasDmsCmr = await models.TicketDms.findOne({
where: {ticketFk: ticket[1]},
include: [{
relation: 'dms',
fields: ['id'],
scope: {
relation: 'dmsType',
scope: {
where: {code: 'cmr'}
}
}
}]
}, options);
expect(hasDmsCmr?.dms()?.dmsType()).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});