salix/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-10-10 10:56:03 +00:00
const models = require('vn-loopback/server/server').models;
describe('ticket moveExpeditions()', () => {
2022-10-20 06:41:00 +00:00
it('should move the selected expeditions to new ticket', async() => {
2022-10-10 10:56:03 +00:00
const tx = await models.Expedition.beginTransaction({});
2022-10-20 06:41:00 +00:00
const ctx = {
req: {accessToken: {userId: 9}},
args: {},
params: {}
};
const myCtx = Object.assign({}, ctx);
2022-10-10 10:56:03 +00:00
try {
const options = {transaction: tx};
2022-10-20 06:41:00 +00:00
myCtx.args = {
clientId: 1101,
landed: new Date(),
warehouseId: 1,
addressId: 121,
agencyModeId: 1,
routeId: null,
expeditionIds: [1, 2]
2022-10-10 10:56:03 +00:00
2022-10-20 06:41:00 +00:00
};
2022-10-10 10:56:03 +00:00
2022-10-20 06:41:00 +00:00
const ticket = await models.Expedition.moveExpeditions(myCtx, options);
const newestTicketIdInFixtures = 27;
expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures);
2022-10-10 10:56:03 +00:00
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});