feat: add backTest
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-02-23 14:53:49 +01:00
parent b3263fb97e
commit ca40eee5ad
2 changed files with 33 additions and 3 deletions

View File

@ -0,0 +1,30 @@
const models = require('vn-loopback/server/server').models;
describe('Client updatePortfolio', () => {
const salesPersonId = 18;
const clienId = 1108;
it('should update the portfolioWeight', async() => {
const tx = await models.Client.beginTransaction({});
try {
const options = {transaction: tx};
const expectedResult = 841.63;
const client = await models.Client.findById(clienId, null, options);
// await client.updateAttribute('salesPersonFk', 18);
await models.Client.rawSql(`UPDATE vn.client SET salesPersonFk = ${salesPersonId} WHERE id = ${clienId}; `);
await models.Client.updatePortfolio();
let [vendedores] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.vendedores WHERE Id_Trabajador = ${salesPersonId}; `, null, options);
expect(vendedores.portfolioWeight).toEqual(expectedResult);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -53,11 +53,11 @@ describe('order filter()', () => {
try {
const options = {transaction: tx};
const filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 18}};
const filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 9}};
const result = await models.Order.filter(myCtx, filter, options);
expect(result.length).toEqual(9);
expect(result[0].id).toEqual(7);
expect(result.length).toEqual(4);
expect(result[0].id).toEqual(19);
await tx.rollback();
} catch (e) {