75 lines
2.6 KiB
JavaScript
75 lines
2.6 KiB
JavaScript
const app = require(`${servicesDir}/ticket/server/server`);
|
|
|
|
describe('ticket componentUpdate()', () => {
|
|
let firstvalueBeforeChange;
|
|
let secondvalueBeforeChange;
|
|
let componentOfSaleSeven = `SELECT value FROM vn.saleComponent
|
|
WHERE saleFk = 7 AND componentFk = 15`;
|
|
|
|
let componentOfSaleEight = `SELECT value FROM vn.saleComponent
|
|
WHERE saleFk = 8 AND componentFk = 15`;
|
|
const today = new Date();
|
|
let ticketId = 11;
|
|
|
|
beforeAll(async() => {
|
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
|
|
firstvalueBeforeChange = componentValue.value;
|
|
|
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleEight);
|
|
secondvalueBeforeChange = componentValue.value;
|
|
});
|
|
|
|
it('should change the agencyMode to modify the sale components value', async() => {
|
|
let data = {
|
|
clientFk: 101,
|
|
agencyModeFk: 8,
|
|
addressFk: 121,
|
|
warehouseFk: 1,
|
|
shipped: today,
|
|
landed: today,
|
|
isDeleted: false,
|
|
hasToBeUnrouted: false,
|
|
option: 1
|
|
};
|
|
|
|
let ctx = {req: {accessToken: {userId: 101}}};
|
|
|
|
await app.models.Ticket.componentUpdate(ticketId, data, ctx);
|
|
|
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
|
|
let firstvalueAfterChange = componentValue.value;
|
|
|
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleEight);
|
|
let secondvalueAfterChange = componentValue.value;
|
|
|
|
expect(firstvalueBeforeChange).not.toEqual(firstvalueAfterChange);
|
|
expect(secondvalueBeforeChange).not.toEqual(secondvalueAfterChange);
|
|
});
|
|
|
|
it('should change the agencyMode to go back to the originals sale components value', async() => {
|
|
let data = {
|
|
clientFk: 101,
|
|
agencyModeFk: 7,
|
|
addressFk: 121,
|
|
warehouseFk: 1,
|
|
shipped: today,
|
|
landed: today,
|
|
isDeleted: false,
|
|
hasToBeUnrouted: false,
|
|
option: 1
|
|
};
|
|
|
|
let ctx = {req: {accessToken: {userId: 101}}};
|
|
await app.models.Ticket.componentUpdate(11, data, ctx);
|
|
|
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
|
|
let firstvalueAfterChange = componentValue.value;
|
|
|
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleEight);
|
|
let secondvalueAfterChange = componentValue.value;
|
|
|
|
expect(firstvalueBeforeChange).toEqual(firstvalueAfterChange);
|
|
expect(secondvalueBeforeChange).toEqual(secondvalueAfterChange);
|
|
});
|
|
});
|