Skip to content

Commit

Permalink
chore(dep) Markdown Transform 0.10.0 and new wrapped version for cond…
Browse files Browse the repository at this point in the history
…itional variables

Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
jeromesimeon committed Feb 18, 2020
1 parent 1ea32b6 commit 78bde2c
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 63 deletions.
82 changes: 27 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/cicero-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
},
"dependencies": {
"@accordproject/concerto-core": "0.82.6",
"@accordproject/ergo-compiler": "0.20.7",
"@accordproject/ergo-engine": "0.20.7",
"@accordproject/markdown-common": "0.9.8",
"@accordproject/ergo-compiler": "0.20.9",
"@accordproject/ergo-engine": "0.20.9",
"@accordproject/markdown-common": "0.10.0",
"axios": "0.19.0",
"debug": "4.1.0",
"ietf-language-tag-regex": "0.0.5",
Expand Down
21 changes: 18 additions & 3 deletions packages/cicero-core/test/clause.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const options = { skipUpdateExternalModels: true };
describe('Clause', () => {

const testLatePenaltyInput = fs.readFileSync(path.resolve(__dirname, 'data/latedeliveryandpenalty', 'text/sample.md'), 'utf8');
const testLatePenaltyInputNoForce = fs.readFileSync(path.resolve(__dirname, 'data/latedeliveryandpenalty', 'text/sample-noforce.md'), 'utf8');
const testLatePenaltyPeriodInput = fs.readFileSync(path.resolve(__dirname, 'data/latedeliveryandpenalty-period', 'text/sample.md'), 'utf8');
const testLatePenaltyCrInput = fs.readFileSync(path.resolve(__dirname, 'data/latedeliveryandpenalty-cr', 'text/sample.md'), 'utf8');
const testCongaInput = fs.readFileSync(path.resolve(__dirname, 'data/conga', 'text/sample.md'), 'utf8');
Expand Down Expand Up @@ -648,21 +649,35 @@ This is more text`;
nl.should.equal(TemplateLoader.normalizeText(testLatePenaltyInput));
});

it('should be able to generate natural language text with wrapped variables', async function() {
it('should be able to generate natural language text with wrapped variables (conditional true)', async function() {
const template = await Template.fromDirectory('./test/data/latedeliveryandpenalty', options);
const clause = new Clause(template);
clause.parse(testLatePenaltyInput);
const nl = await clause.draft({ wrapVariables: true });
nl.should.equal(`Late Delivery and Penalty
----
In case of delayed delivery<if id="forceMajeure" value="%20except%20for%20Force%20Majeure%20cases%2C"/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="9%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="7.0"/>% of the total value of the Equipment whose delivery has been delayed.
In case of delayed delivery<if id="forceMajeure" value="%20except%20for%20Force%20Majeure%20cases%2C" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="9%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="7.0"/>% of the total value of the Equipment whose delivery has been delayed.
1. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>.
1. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="2.0"/>% of the total value of the Equipment involved in late delivery.
1. If the delay is more than <variable id="termination" value="2%20weeks"/>, the Buyer is entitled to terminate this Contract.`);
});

it('should be able to generate natural language text with wrapped variables and formatted dates', async function() {
it('should be able to generate natural language text with wrapped variables (conditional false)', async function() {
const template = await Template.fromDirectory('./test/data/latedeliveryandpenalty', options);
const clause = new Clause(template);
clause.parse(testLatePenaltyInputNoForce);
const nl = await clause.draft({ wrapVariables: true });
nl.should.equal(`Late Delivery and Penalty
----
In case of delayed delivery<if id="forceMajeure" value="" whenTrue="%20except%20for%20Force%20Majeure%20cases%2C" whenFalse=""/> the Seller shall pay to the Buyer for every <variable id="penaltyDuration" value="9%20days"/> of delay penalty amounting to <variable id="penaltyPercentage" value="7.0"/>% of the total value of the Equipment whose delivery has been delayed.
1. Any fractional part of a <variable id="fractionalPart" value="days"/> is to be considered a full <variable id="fractionalPart" value="days"/>.
1. The total amount of penalty shall not however, exceed <variable id="capPercentage" value="2.0"/>% of the total value of the Equipment involved in late delivery.
1. If the delay is more than <variable id="termination" value="2%20weeks"/>, the Buyer is entitled to terminate this Contract.`);
});

it('should be able to generate natural language text with wrapped variables (formatted dates)', async function() {
const template = await Template.fromDirectory('./test/data/formatted-dates-DD_MM_YYYY', options);
const clause = new Clause(template);
clause.parse('dateTimeProperty: 01/12/2018');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Late Delivery and Penalty
----

In case of delayed delivery the Seller shall pay to the Buyer for every 9 days of delay penalty amounting to 7.0% of the total value of the Equipment whose delivery has been delayed.
1. Any fractional part of a days is to be considered a full days.
1. The total amount of penalty shall not however, exceed 2.0% of the total value of the Equipment involved in late delivery.
1. If the delay is more than 2 weeks, the Buyer is entitled to terminate this Contract.
2 changes: 1 addition & 1 deletion packages/cicero-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"dependencies": {
"@accordproject/cicero-core": "0.20.8",
"@accordproject/ergo-engine": "0.20.7",
"@accordproject/ergo-engine": "0.20.9",
"moment-mini": "2.22.1"
},
"license-check-config": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cicero-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"@accordproject/cicero-core": "0.20.8",
"@accordproject/cicero-engine": "0.20.8",
"@accordproject/ergo-test": "0.20.7",
"@accordproject/ergo-test": "0.20.9",
"chai": "4.2.0",
"chai-things": "0.2.0",
"cucumber": "5.1.0"
Expand Down

0 comments on commit 78bde2c

Please sign in to comment.