Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
dff78922a1
|
@ -11,9 +11,9 @@ describe('buyUltimate()', () => {
|
||||||
let query = `
|
let query = `
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
CALL vn.buyUltimate(?, ?);
|
CALL vn.buyUltimate(?, ?);
|
||||||
SELECT * FROM tmp.buyUltimate;
|
SELECT * FROM tmp.buyUltimate ORDER BY 'id' DESC;
|
||||||
|
|
||||||
ROLLBACK;`;
|
ROLLBACK;`;
|
||||||
|
|
||||||
let result = await app.models.Ticket.rawSql(query, [
|
let result = await app.models.Ticket.rawSql(query, [
|
||||||
params.warehouseFk,
|
params.warehouseFk,
|
||||||
params.date
|
params.date
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
const app = require(`../../../ticket/server/server`);
|
||||||
|
|
||||||
|
describe('buyUltimateFromInterval()', () => {
|
||||||
|
let today;
|
||||||
|
let future;
|
||||||
|
beforeAll(() => {
|
||||||
|
let date = new Date();
|
||||||
|
let month = `${date.getMonth() + 1}`;
|
||||||
|
let futureMonth = `${date.getMonth() + 2}`;
|
||||||
|
let day = date.getDate();
|
||||||
|
let year = date.getFullYear();
|
||||||
|
|
||||||
|
if (month.toString().length < 2) month = '0' + month;
|
||||||
|
if (futureMonth.toString().length < 2) month = '0' + month;
|
||||||
|
if (day.toString().length < 2) day = `0${day}`;
|
||||||
|
|
||||||
|
today = [year, month, day].join('-');
|
||||||
|
future = [year, futureMonth, day].join('-');
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should create a temporal table with it's data`, async() => {
|
||||||
|
let params = {
|
||||||
|
warehouseFk: 1,
|
||||||
|
started: today,
|
||||||
|
ended: today
|
||||||
|
};
|
||||||
|
|
||||||
|
let query = `
|
||||||
|
START TRANSACTION;
|
||||||
|
CALL vn.buyUltimateFromInterval(?, ?, ?);
|
||||||
|
SELECT * FROM tmp.buyUltimateFromInterval;
|
||||||
|
ROLLBACK;`;
|
||||||
|
|
||||||
|
let result = await app.models.Ticket.rawSql(query, [
|
||||||
|
params.warehouseFk,
|
||||||
|
params.started,
|
||||||
|
params.ended
|
||||||
|
]);
|
||||||
|
|
||||||
|
let buyUltimateFromIntervalTable = result[2];
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable.length).toEqual(2);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].itemFk).toEqual(1);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].itemFk).toEqual(3);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].warehouseFk).toEqual(1);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].warehouseFk).toEqual(1);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].landed).toEqual(today);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].landed).toEqual(today);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should create a temporal table with it's data in which started value is assigned to ended`, async() => {
|
||||||
|
let params = {
|
||||||
|
warehouseFk: 1,
|
||||||
|
started: today,
|
||||||
|
ended: null
|
||||||
|
};
|
||||||
|
|
||||||
|
let query = `
|
||||||
|
START TRANSACTION;
|
||||||
|
CALL vn.buyUltimateFromInterval(?, ?, ?);
|
||||||
|
SELECT * FROM tmp.buyUltimateFromInterval;
|
||||||
|
ROLLBACK;`;
|
||||||
|
|
||||||
|
let result = await app.models.Ticket.rawSql(query, [
|
||||||
|
params.warehouseFk,
|
||||||
|
params.started,
|
||||||
|
params.ended
|
||||||
|
]);
|
||||||
|
|
||||||
|
let buyUltimateFromIntervalTable = result[2];
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable.length).toEqual(2);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].itemFk).toEqual(1);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].itemFk).toEqual(3);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].warehouseFk).toEqual(1);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].warehouseFk).toEqual(1);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].landed).toEqual(today);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].landed).toEqual(today);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should create a temporal table with it's data in which ended value is a date in the future`, async() => {
|
||||||
|
let params = {
|
||||||
|
warehouseFk: 1,
|
||||||
|
started: today,
|
||||||
|
ended: future
|
||||||
|
};
|
||||||
|
|
||||||
|
let query = `
|
||||||
|
START TRANSACTION;
|
||||||
|
CALL vn.buyUltimateFromInterval(?, ?, ?);
|
||||||
|
SELECT * FROM tmp.buyUltimateFromInterval;
|
||||||
|
ROLLBACK;`;
|
||||||
|
|
||||||
|
let result = await app.models.Ticket.rawSql(query, [
|
||||||
|
params.warehouseFk,
|
||||||
|
params.started,
|
||||||
|
params.ended
|
||||||
|
]);
|
||||||
|
|
||||||
|
let buyUltimateFromIntervalTable = result[2];
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable.length).toEqual(2);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].itemFk).toEqual(1);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].itemFk).toEqual(3);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].warehouseFk).toEqual(1);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].warehouseFk).toEqual(1);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5);
|
||||||
|
|
||||||
|
expect(buyUltimateFromIntervalTable[0].landed).toEqual(today);
|
||||||
|
expect(buyUltimateFromIntervalTable[1].landed).toEqual(today);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue