exframe-document-validator
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -6,2 +6,4 @@ 'use strict'; | ||
const customObjects = { Math }; | ||
const checkLogger = (context) => { | ||
@@ -32,3 +34,3 @@ const newContext = context; | ||
coverageDetails.coverageOptions.forEach((rawOption) => { | ||
const transform = compile(rawOption, {}); | ||
const transform = compile(rawOption, { customObjects }); | ||
const option = document ? transform(document) : rawOption; | ||
@@ -69,3 +71,3 @@ coField.children.push(`coverageOptions.${option.name}`); | ||
coverageDetails.coverageLimits.forEach((rawLimit) => { | ||
const transform = compile(rawLimit, {}); | ||
const transform = compile(rawLimit, { customObjects }); | ||
const limit = document ? transform(document) : rawLimit; | ||
@@ -117,3 +119,3 @@ clField.children.push(`coverageLimits.${limit.name}`); | ||
coverageDetails.deductibles.forEach((rawDeductible) => { | ||
const transform = compile(rawDeductible, {}); | ||
const transform = compile(rawDeductible, { customObjects }); | ||
const deductible = document ? transform(document) : rawDeductible; | ||
@@ -120,0 +122,0 @@ deductibleField.children.push(`deductibles.${deductible.name}`); |
{ | ||
"name": "exframe-document-validator", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -261,2 +261,16 @@ 'use strict'; | ||
}); | ||
it('Does not fail when using Math within json-transpose', () => { | ||
const coverageDetails = cloneDeep(baseDetails); | ||
delete coverageDetails.coverageLimits; | ||
coverageDetails.coverageLimits = [ | ||
{ | ||
name: 'dwelling', | ||
required: true, | ||
amount: '${Math.round(it.coverageLimits.dwelling.amount)}' | ||
} | ||
] | ||
const document = cloneDeep(baseDocument); | ||
const fields = () => documentLib.addCoverageLimits(coverageDetails, document); | ||
expect(fields).to.not.throw(); | ||
}); | ||
it('Returns only the coverageLimits field when there are no coverageLimits', () => { | ||
@@ -263,0 +277,0 @@ const coverageDetails = cloneDeep(baseDetails); |
39708
1072