2024-02-07 15:52:43 +00:00
|
|
|
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,
|
2024-02-12 08:24:37 +00:00
|
|
|
'agencyModeFk': 999
|
2024-02-07 15:52:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const expedition1 = {
|
|
|
|
'id': 14,
|
2024-02-12 08:24:37 +00:00
|
|
|
'agencyModeFk': 999,
|
2024-02-07 15:52:43 +00:00
|
|
|
'ticketFk': 44,
|
|
|
|
'freightItemFk': 71,
|
|
|
|
'created': '2001-01-01',
|
|
|
|
'counter': 1,
|
|
|
|
'workerFk': 18,
|
|
|
|
'packagingFk': '94',
|
|
|
|
'hostFk': '',
|
|
|
|
'stateTypeFk': 3,
|
|
|
|
'hasNewRoute': 0,
|
|
|
|
'isBox': 71,
|
|
|
|
'editorFk': 100
|
|
|
|
};
|
2024-02-12 08:24:37 +00:00
|
|
|
const tusabeh = async() => {
|
|
|
|
return {};
|
|
|
|
};
|
|
|
|
|
2024-02-07 15:52:43 +00:00
|
|
|
fdescribe('MRWConfig createShipment()', () => {
|
2024-02-12 08:24:37 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2024-02-07 15:52:43 +00:00
|
|
|
it('should create a shipment and return a base64Binary label', async() => {
|
2024-02-12 08:24:37 +00:00
|
|
|
const options = {transaction: await models.MrwConfig.beginTransaction({})};
|
|
|
|
await models.Agency.create(
|
|
|
|
{'id': 999, 'name': 'mrw'},
|
|
|
|
options
|
|
|
|
);
|
|
|
|
|
|
|
|
await models.AgencyMode.create(
|
|
|
|
{'id': 999, 'name': 'mrw', 'agencyFk': 999, 'code': 'mrw'},
|
|
|
|
options
|
|
|
|
);
|
2024-02-07 15:52:43 +00:00
|
|
|
|
2024-02-12 08:24:37 +00:00
|
|
|
await models.MrwConfig.create(
|
|
|
|
{
|
|
|
|
'url': 'https://url.com',
|
|
|
|
'user': 'user',
|
|
|
|
'password': 'password',
|
|
|
|
'franchiseCode': 'franchiseCode',
|
|
|
|
'subscriberCode': 'subscriberCode'
|
|
|
|
}, options
|
|
|
|
);
|
2024-02-07 15:52:43 +00:00
|
|
|
|
2024-02-12 08:24:37 +00:00
|
|
|
await models.Application.rawSql(
|
|
|
|
`INSERT INTO vn.mrwService
|
|
|
|
SET agencyModeCodeFk = 'mrw',
|
|
|
|
clientType = 1,
|
|
|
|
serviceType = 1,
|
|
|
|
kg = 1`, null, options
|
|
|
|
);
|
|
|
|
const ticket = models.Ticket.create(ticket1, options);
|
|
|
|
const expedition = models.Expedition.create(expedition1, options);
|
2024-02-07 15:52:43 +00:00
|
|
|
spyOn(axios, 'post').and.returnValues([{data: mockShipmentId}, {data: mockBase64Binary}]);
|
|
|
|
|
|
|
|
const base64Binary = await models.MrwConfig.createShipment(expedition.id, options);
|
|
|
|
|
|
|
|
expect(base64Binary).toEqual(mockBase64Binary);
|
2024-02-12 08:24:37 +00:00
|
|
|
expect(1).toEqual(1);
|
2024-02-07 15:52:43 +00:00
|
|
|
});
|
|
|
|
});
|
2024-02-12 08:24:37 +00:00
|
|
|
|