UNPKG

923 BJavaScriptView Raw
1import fs from 'fs';
2import { interpreter } from '../src';
3import path from 'path';
4
5const EXPECTATIONS_DIR = path.join(__dirname, 'data/interpreter-test-suite/reduce_decision_rules');
6
7// List the expectations file
8const expectationsFiles = fs.readdirSync(EXPECTATIONS_DIR);
9
10describe('interpreter.reduceDecisionRules', () => {
11 _.each(expectationsFiles, (expectationsFile) => {
12 describe(`"${expectationsFile}"`, function() {
13 // Load the tree
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});