salix/modules/ticket/back/methods/expedition-pallet/specs/getPallet.spec.js

34 lines
981 B
JavaScript

const {models} = require('vn-loopback/server/server');
describe('expeditonPallet getPallet()', () => {
beforeAll(async() => {
ctx = {
accessToken: {userId: 9},
req: {
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
it('should obtain the pallet data', async() => {
const palletId = 1;
const pallet = await models.ExpeditionPallet.getPallet(ctx, palletId);
expect(pallet).toBeDefined();
expect(pallet.truckFk).toEqual(1);
expect(pallet.description).toEqual('BEST TRUCK IN FLEET');
});
it('should throw an error when the pallet does not exist', async() => {
const palletId = 600;
try {
await models.ExpeditionPallet.getPallet(ctx, palletId);
} catch (e) {
const error = e;
expect(error.message).toEqual('This pallet does not exist');
}
});
});