1 | import fs from 'fs';
|
2 | import { interpreter } from '../src';
|
3 | import path from 'path';
|
4 |
|
5 | const EXPECTATIONS_DIR = path.join(__dirname, 'data/interpreter-test-suite/reduce_decision_rules');
|
6 |
|
7 |
|
8 | const expectationsFiles = fs.readdirSync(EXPECTATIONS_DIR);
|
9 |
|
10 | describe('interpreter.reduceDecisionRules', () => {
|
11 | _.each(expectationsFiles, (expectationsFile) => {
|
12 | describe(`"${expectationsFile}"`, function() {
|
13 |
|
14 | const expectations = require(path.join(EXPECTATIONS_DIR, expectationsFile));
|
15 |
|
16 | _.each(expectations, ({ title, expectation, rules }) => {
|
17 | it(title, function() {
|
18 | if (expectation.error) {
|
19 | expect(() => interpreter.reduceDecisionRules(rules)).to.throw();
|
20 | }
|
21 | else {
|
22 | expect(interpreter.reduceDecisionRules(rules)).to.be.deep.equal(expectation.rules);
|
23 | }
|
24 | });
|
25 | });
|
26 | });
|
27 | });
|
28 | });
|