46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
|
const models = require('vn-loopback/server/server').models;
|
||
|
const axios = require('axios');
|
||
|
|
||
|
const expeditionFk = 14;
|
||
|
const mockShipmentId = 'baseMockShipmentId';
|
||
|
const mockBase64Binary = 'base64BinaryString';
|
||
|
const ticket1 = {
|
||
|
'id': '44',
|
||
|
'clientFk': 1101,
|
||
|
'shipped': Date.vnNew(),
|
||
|
'nickname': 'MRW',
|
||
|
'addressFk': 1,
|
||
|
'agencyModeFk': 26
|
||
|
};
|
||
|
|
||
|
const expedition1 = {
|
||
|
'id': 14,
|
||
|
'agencyModeFk': 26,
|
||
|
'ticketFk': 44,
|
||
|
'freightItemFk': 71,
|
||
|
'created': '2001-01-01',
|
||
|
'counter': 1,
|
||
|
'workerFk': 18,
|
||
|
'packagingFk': '94',
|
||
|
'hostFk': '',
|
||
|
'stateTypeFk': 3,
|
||
|
'hasNewRoute': 0,
|
||
|
'isBox': 71,
|
||
|
'editorFk': 100
|
||
|
};
|
||
|
fdescribe('MRWConfig createShipment()', () => {
|
||
|
it('should create a shipment and return a base64Binary label', async() => {
|
||
|
const tx = await models.MrwConfig.beginTransaction({});
|
||
|
const options = {transaction: tx};
|
||
|
|
||
|
await models.Ticket.create(ticket1, options);
|
||
|
const expedition = await models.Expedition.create(expedition1, options);
|
||
|
|
||
|
spyOn(axios, 'post').and.returnValues([{data: mockShipmentId}, {data: mockBase64Binary}]);
|
||
|
|
||
|
const base64Binary = await models.MrwConfig.createShipment(expedition.id, options);
|
||
|
|
||
|
expect(base64Binary).toEqual(mockBase64Binary);
|
||
|
});
|
||
|
});
|