45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
|
|
|
describe('ticket moveExpeditions()', () => {
|
|
beforeAll(async() => {
|
|
mockLoopBackContext();
|
|
});
|
|
|
|
it('should move the selected expeditions to new ticket', async() => {
|
|
const tx = await models.Expedition.beginTransaction({});
|
|
const ctx = {
|
|
req: {accessToken: {userId: 9}},
|
|
args: {},
|
|
params: {}
|
|
};
|
|
const myCtx = Object.assign({}, ctx);
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
myCtx.args = {
|
|
clientId: 1101,
|
|
landed: Date.vnNew(),
|
|
warehouseId: 1,
|
|
addressId: 121,
|
|
agencyModeId: 1,
|
|
routeId: null,
|
|
expeditionIds: [1, 2]
|
|
|
|
};
|
|
|
|
const ticket = await models.Expedition.moveExpeditions(myCtx, options);
|
|
|
|
const newestTicketIdInFixtures = 27;
|
|
|
|
expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures);
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|
|
|