feat: add backTest
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-07-08 10:09:03 +02:00
parent eb586643ca
commit 4b65b531fd
2 changed files with 44 additions and 6 deletions

View File

@ -1,17 +1,17 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('zone exclusionGeo()', () => { describe('zone exclusionGeo()', () => {
const zoneId = 1;
const today = new Date();
it(`should show an error when location isn't selected`, async() => { it(`should show an error when location isn't selected`, async() => {
const tx = await models.Zone.beginTransaction({}); const tx = await models.Zone.beginTransaction({});
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const today = new Date();
const zoneId = 1;
const geoIds = []; const geoIds = [];
const result = await models.Zone.exclusionGeo(zoneId, today, geoIds, options);
expect(result.length).toEqual(2); await models.Zone.exclusionGeo(zoneId, today, geoIds, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -27,8 +27,6 @@ describe('zone exclusionGeo()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const today = new Date();
const zoneId = 1;
const geoIds = [{id: 1}, {id: 2}]; const geoIds = [{id: 1}, {id: 2}];
const result = await models.Zone.exclusionGeo(zoneId, today, geoIds, options); const result = await models.Zone.exclusionGeo(zoneId, today, geoIds, options);

View File

@ -0,0 +1,40 @@
const models = require('vn-loopback/server/server').models;
describe('zone updateExclusionGeo()', () => {
it(`should show an error when location isn't selected`, async() => {
const tx = await models.Zone.beginTransaction({});
try {
const options = {transaction: tx};
const zoneId = 1;
const geoIds = [];
await models.Zone.updateExclusionGeo(zoneId, geoIds, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toContain(`You must select a location`);
});
it('should delete all exclusion and then create two exclusion by geo for a zone', async() => {
const tx = await models.Zone.beginTransaction({});
try {
const options = {transaction: tx};
const zoneId = 2;
const geoIds = [{id: 1}, {id: 2}];
const result = await models.Zone.updateExclusionGeo(zoneId, geoIds, options);
expect(result.length).toEqual(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});