salix/services/loopback/common/methods/ticket/specs/threeLastActive.spec.js

19 lines
851 B
JavaScript

const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket threeLastActive()', () => {
it('should return the last three active tickets', async() => {
let expectedResult = [
{id: 12, shipped: '2018-09-14 00:00:00', agencyName: 'inhouse pickup', warehouseName: 'Warehouse One'},
{id: 13, shipped: '2018-10-14 00:00:00', agencyName: 'Super-Man delivery', warehouseName: 'Warehouse Two'},
{id: 14, shipped: '2018-11-14 00:00:00', agencyName: 'Super-Man delivery', warehouseName: 'Warehouse Two'}
];
expectedResult = JSON.stringify(expectedResult);
let params = {clientFk: 101, ticketFk: 1};
let result = await app.models.Ticket.threeLastActive(params);
result = JSON.stringify(result);
expect(result).toEqual(expectedResult);
});
});