test: refs #8361 enhance exchangeRateUpdate specs to validate day1 and day2 entries without backfilling day3
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
73d5d508ce
commit
786f1fe661
|
@ -141,4 +141,50 @@ describe('exchangeRateUpdate functionality', function() {
|
|||
|
||||
expect(afterCount - beforeCount).toBe(4);
|
||||
});
|
||||
|
||||
fit('should create entries for day1 and day2 from the feed, and not backfill day3', async function() {
|
||||
const lastRate = await models.ReferenceRate.findOne({order: 'dated DESC'}, options);
|
||||
if (!lastRate) return fail('No existing ReferenceRate data in DB');
|
||||
|
||||
const currency = await models.Currency.findById(lastRate.currencyFk, null, options);
|
||||
if (!currency) return fail(`No currency for ID ${lastRate.currencyFk}`);
|
||||
|
||||
const day1 = new Date(lastRate.dated);
|
||||
day1.setDate(day1.getDate() + 1);
|
||||
|
||||
const day2 = new Date(lastRate.dated);
|
||||
day2.setDate(day2.getDate() + 2);
|
||||
|
||||
const day3 = new Date(lastRate.dated);
|
||||
day3.setDate(day3.getDate() + 3);
|
||||
|
||||
const xml = `<Cube>
|
||||
<Cube time='${formatYmd(day1)}'>
|
||||
<Cube currency='${currency.code}' rate='1.1'/>
|
||||
</Cube>
|
||||
<Cube time='${formatYmd(day2)}'>
|
||||
<Cube currency='${currency.code}' rate='2.2'/>
|
||||
</Cube>
|
||||
</Cube>`;
|
||||
|
||||
axios.get.and.returnValue(Promise.resolve({data: xml}));
|
||||
|
||||
await models.InvoiceIn.exchangeRateUpdate(options);
|
||||
|
||||
const day3Record = await models.ReferenceRate.findOne({
|
||||
where: {currencyFk: currency.id, dated: day3}
|
||||
}, options);
|
||||
|
||||
expect(day3Record).toBeNull();
|
||||
|
||||
const day1Record = await models.ReferenceRate.findOne({
|
||||
where: {currencyFk: currency.id, dated: day1}
|
||||
}, options);
|
||||
const day2Record = await models.ReferenceRate.findOne({
|
||||
where: {currencyFk: currency.id, dated: day2}
|
||||
}, options);
|
||||
|
||||
expect(day1Record.value).toBeCloseTo('1.1');
|
||||
expect(day2Record.value).toBeCloseTo('2.2');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue