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;
describe('zone exclusionGeo()', () => {
const zoneId = 1;
const today = new Date();
it(`should show an error when location isn't selected`, async() => {
const tx = await models.Zone.beginTransaction({});
try {
const options = {transaction: tx};
const today = new Date();
const zoneId = 1;
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();
} catch (e) {
@ -27,8 +27,6 @@ describe('zone exclusionGeo()', () => {
try {
const options = {transaction: tx};
const today = new Date();
const zoneId = 1;
const geoIds = [{id: 1}, {id: 2}];
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;
}
});
});