diff --git a/examples/initemittest/logic.ergo b/examples/initemittest/logic.ergo
index b48ba8df3..57308e2ae 100644
--- a/examples/initemittest/logic.ergo
+++ b/examples/initemittest/logic.ergo
@@ -21,4 +21,10 @@ contract InitEmitTest over TemplateModel state State {
return Response{
}
}
+ clause greet(request:Request) : Response {
+ set state State {};
+ emit Greeting{ message: "Voila!" };
+ return Response{
+ }
+ }
}
diff --git a/examples/initemittest/state.json b/examples/initemittest/state.json
index 2245874c6..bac6950b2 100644
--- a/examples/initemittest/state.json
+++ b/examples/initemittest/state.json
@@ -1,2 +1 @@
-{ "$class": "org.accordproject.cicero.contract.AccordContractState",
- "stateId" : "1" }
+{ "$class": "org.accordproject.initemittest.State" }
diff --git a/packages/ergo-cli/.cucumber.js b/packages/ergo-cli/.cucumber.js
index a6298b493..859adba76 100644
--- a/packages/ergo-cli/.cucumber.js
+++ b/packages/ergo-cli/.cucumber.js
@@ -1 +1 @@
-require('@accordproject/ergo-engine/lib/steps');
+require('@accordproject/ergo-test').Steps;
diff --git a/packages/ergo-cli/package.json b/packages/ergo-cli/package.json
index 8f7a54f71..a122d73fd 100644
--- a/packages/ergo-cli/package.json
+++ b/packages/ergo-cli/package.json
@@ -30,6 +30,7 @@
"dependencies": {
"@accordproject/ergo-compiler": "0.7.3",
"@accordproject/ergo-engine": "0.7.3",
+ "@accordproject/ergo-test": "0.7.3",
"moment-mini": "2.22.1",
"jsome": "2.5.0",
"winston": "^3.2.1",
diff --git a/packages/ergo-engine/README.md b/packages/ergo-engine/README.md
index cfeb264e6..efc52eb3e 100644
--- a/packages/ergo-engine/README.md
+++ b/packages/ergo-engine/README.md
@@ -2,7 +2,7 @@
Core classes for executing Ergo contract logic using the JavaScript backend
-The Ergo code is compiled to JavaScript and executed using the `vm2` npm module, which provides (somehwat)sandboxed execution.
+The Ergo code is compiled to JavaScript and executed using the `vm2` npm module, which provides sandboxed execution.
## Installation
@@ -12,5 +12,5 @@ npm install @accordproject/ergo-engine --save
## More information
-[Ergo Language](https://ergo.accordproject.org)
+[Accord Project Documentation](https://docs.accordproject.org)
diff --git a/packages/ergo-engine/lib/util.js b/packages/ergo-engine/lib/util.js
index 90a91ab97..2dbff5291 100644
--- a/packages/ergo-engine/lib/util.js
+++ b/packages/ergo-engine/lib/util.js
@@ -17,26 +17,9 @@
// Moment serialization function to preserves utcOffset. See https://momentjs.com/docs/#/displaying/as-json/
const momentToJson = function() { return this.format(); };
-const Chai = require('chai');
-const expect = Chai.expect;
-
const Moment = require('moment-mini');
Moment.fn.toJSON = momentToJson;
-/**
- * Resolve the root directory
- *
- * @param {string} parameters Cucumber's World parameters
- * @return {string} root directory used to resolve file names
- */
-function resolveRootDir(parameters) {
- if (parameters.rootdir) {
- return parameters.rootdir;
- } else {
- return '.';
- }
-}
-
/**
* Ensures there is a proper current time
*
@@ -56,50 +39,4 @@ function setCurrentTime(currentTime) {
}
}
-/**
- * Compare actual and expected result components
- *
- * @param {string} expected the expected component as specified in the test workload
- * @param {string} actual the actual component as returned by the engine
- */
-function compareComponent(expected,actual) {
- if (!expected) {
- expect(actual).to.equal(expected);
- } else {
- delete expected.timestamp;
- delete actual.timestamp;
- // Some basic deep comparison for arrays, since Chai doesn't do the right thing
- if (Array.isArray(actual)) {
- for (let i = 0; i < expected.length; i++) {
- delete expected[i].timestamp;
- delete actual[i].timestamp;
- expect(actual[i]).to.deep.include(expected[i]);
- }
- } else {
- expect(actual).to.deep.include(expected);
- }
- }
-}
-
-/**
- * Compare actual result and expected result
- *
- * @param {string} expected the expected successful result as specified in the test workload
- * @param {string} actual the successful result as returned by the engine
- */
-function compareSuccess(expected,actual) {
- if (expected.hasOwnProperty('state')) {
- expect(actual).to.have.property('state');
- compareComponent(expected.state, actual.state);
- }
- if (expected.hasOwnProperty('response')) {
- expect(actual).to.have.property('response');
- compareComponent(expected.response, actual.response);
- }
- if (expected.hasOwnProperty('emit')) {
- expect(actual).to.have.property('emit');
- compareComponent(expected.emit, actual.emit);
- }
-}
-
-module.exports = { momentToJson, resolveRootDir, setCurrentTime, compareComponent, compareSuccess };
+module.exports = { momentToJson, setCurrentTime };
diff --git a/packages/ergo-engine/package.json b/packages/ergo-engine/package.json
index 02cc4e3c9..3d175df11 100644
--- a/packages/ergo-engine/package.json
+++ b/packages/ergo-engine/package.json
@@ -13,8 +13,7 @@
"postlint": "npm run licchk",
"licchk": "license-check",
"test:mocha": "mocha",
- "test:cucumber": "cucumber-js test/features --require lib/steps.js --world-parameters '{\"rootdir\":\"./test\"}'",
- "test:all": "npm run test:mocha && npm run test:cucumber",
+ "test:all": "npm run test:mocha",
"test:cov": "nyc npm run test:all",
"test": "npm run test:all && npm run test:cov"
},
@@ -39,7 +38,6 @@
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"chai-things": "0.2.0",
- "cucumber": "^5.1.0",
"eslint": "4.19.1",
"jsdoc": "3.5.5",
"lerna": "2.11.0",
diff --git a/packages/ergo-engine/test/engine.js b/packages/ergo-engine/test/engine.js
index a3e59f2b9..09d60a89b 100644
--- a/packages/ergo-engine/test/engine.js
+++ b/packages/ergo-engine/test/engine.js
@@ -15,8 +15,8 @@
'use strict';
const Engine = require('../lib/engine');
-const Util = require('../lib/util');
const TemplateLogic = require('@accordproject/ergo-compiler').TemplateLogic;
+
const Chai = require('chai');
const expect = Chai.expect;
@@ -30,6 +30,52 @@ const Path = require('path');
// Set of tests
const workload = JSON.parse(Fs.readFileSync(Path.resolve(__dirname, 'workload.json'), 'utf8'));
+/**
+ * Compare actual and expected result components
+ *
+ * @param {string} expected the expected component as specified in the test workload
+ * @param {string} actual the actual component as returned by the engine
+ */
+function compareComponent(expected,actual) {
+ if (!expected) {
+ expect(actual).to.equal(expected);
+ } else {
+ delete expected.timestamp;
+ delete actual.timestamp;
+ // Some basic deep comparison for arrays, since Chai doesn't do the right thing
+ if (Array.isArray(actual)) {
+ for (let i = 0; i < expected.length; i++) {
+ delete expected[i].timestamp;
+ delete actual[i].timestamp;
+ expect(actual[i]).to.deep.include(expected[i]);
+ }
+ } else {
+ expect(actual).to.deep.include(expected);
+ }
+ }
+}
+
+/**
+ * Compare actual result and expected result
+ *
+ * @param {string} expected the expected successful result as specified in the test workload
+ * @param {string} actual the successful result as returned by the engine
+ */
+function compareSuccess(expected,actual) {
+ if (expected.hasOwnProperty('state')) {
+ expect(actual).to.have.property('state');
+ compareComponent(expected.state, actual.state);
+ }
+ if (expected.hasOwnProperty('response')) {
+ expect(actual).to.have.property('response');
+ compareComponent(expected.response, actual.response);
+ }
+ if (expected.hasOwnProperty('emit')) {
+ expect(actual).to.have.property('emit');
+ compareComponent(expected.emit, actual.emit);
+ }
+}
+
describe('Execute ES6', () => {
let engine;
@@ -83,7 +129,7 @@ describe('Execute ES6', () => {
} else {
return engine.compileAndInit(templateLogic, contractName, contractJson, currentTime)
.then((actualAnswer) => {
- return Util.compareSuccess(expected, actualAnswer);
+ return compareSuccess(expected, actualAnswer);
});
}
} else {
@@ -99,7 +145,7 @@ describe('Execute ES6', () => {
} else {
return engine.compileAndInvoke(templateLogic, contractName, clauseName, contractJson, params, stateJson, currentTime)
.then((actualAnswer) => {
- return Util.compareSuccess(expected, actualAnswer);
+ return compareSuccess(expected, actualAnswer);
});
}
} else {
@@ -113,7 +159,7 @@ describe('Execute ES6', () => {
} else {
return engine.compileAndExecute(templateLogic, contractName, contractJson, requestJson, stateJson, currentTime)
.then((actualAnswer) => {
- return Util.compareSuccess(expected, actualAnswer);
+ return compareSuccess(expected, actualAnswer);
});
}
}
@@ -174,7 +220,7 @@ describe('Execute ES5', () => {
} else {
return engine.compileAndInit(templateLogic, contractName, contractJson, currentTime)
.then((actualAnswer) => {
- return Util.compareSuccess(expected, actualAnswer);
+ return compareSuccess(expected, actualAnswer);
});
}
} else {
@@ -190,7 +236,7 @@ describe('Execute ES5', () => {
} else {
return engine.compileAndInvoke(templateLogic, contractName, clauseName, contractJson, params, stateJson, currentTime)
.then((actualAnswer) => {
- return Util.compareSuccess(expected, actualAnswer);
+ return compareSuccess(expected, actualAnswer);
});
}
} else {
@@ -204,7 +250,7 @@ describe('Execute ES5', () => {
} else {
return engine.compileAndExecute(templateLogic, contractName, contractJson, requestJson, stateJson, currentTime)
.then((actualAnswer) => {
- return Util.compareSuccess(expected, actualAnswer);
+ return compareSuccess(expected, actualAnswer);
});
}
}
diff --git a/packages/ergo-engine/test/util.js b/packages/ergo-engine/test/util.js
index 3d2c19bd8..46d9345ef 100644
--- a/packages/ergo-engine/test/util.js
+++ b/packages/ergo-engine/test/util.js
@@ -41,11 +41,3 @@ describe('Initialize current time', () => {
return Util.setCurrentTime(undefined).format().should.not.be.null;
});
});
-describe('Resolve root directory for Cucumber', () => {
- it('Should resolve to given root directory', function () {
- return Util.resolveRootDir({rootdir:'foo/bar'}).should.equal('foo/bar');
- });
- it('Should resolve to \'.\'', function () {
- return Util.resolveRootDir({}).should.equal('.');
- });
-});
diff --git a/packages/ergo-engine/test/workload.json b/packages/ergo-engine/test/workload.json
index f2d64569a..f725ebf4a 100644
--- a/packages/ergo-engine/test/workload.json
+++ b/packages/ergo-engine/test/workload.json
@@ -106,6 +106,48 @@
}
}
},
+ {
+ "name": "initemittest",
+ "dir": "examples/initemittest",
+ "ergo": ["logic.ergo"],
+ "models": ["model.cto"],
+ "contract": "contract.json",
+ "request": "request.json",
+ "state": null,
+ "contractName": "org.accordproject.initemittest.InitEmitTest",
+ "currentTime": null,
+ "expected": {
+ "response": {
+ "$class": "org.accordproject.initemittest.Response"
+ },
+ "state": {
+ "$class": "org.accordproject.initemittest.State"
+ }
+ }
+ },
+ {
+ "name": "initemittest (greeting)",
+ "dir": "examples/initemittest",
+ "ergo": ["logic.ergo"],
+ "models": ["model.cto"],
+ "contract": "contract.json",
+ "request": "request.json",
+ "state": "state.json",
+ "contractName": "org.accordproject.initemittest.InitEmitTest",
+ "currentTime": null,
+ "expected": {
+ "response": {
+ "$class": "org.accordproject.initemittest.Response"
+ },
+ "state": {
+ "$class": "org.accordproject.initemittest.State"
+ },
+ "emit": [{
+ "$class": "org.accordproject.initemittest.Greeting",
+ "message": "Voila!"
+ }]
+ }
+ },
{
"name": "bad logic",
"dir": "examples/bad-logic",
diff --git a/packages/ergo-test/.eslintignore b/packages/ergo-test/.eslintignore
new file mode 100644
index 000000000..a081e07e2
--- /dev/null
+++ b/packages/ergo-test/.eslintignore
@@ -0,0 +1,6 @@
+coverage
+docs
+node_modules
+out
+test/data
+lib/momenttojson.js
diff --git a/packages/ergo-test/.eslintrc.yml b/packages/ergo-test/.eslintrc.yml
new file mode 100644
index 000000000..8ff0a057c
--- /dev/null
+++ b/packages/ergo-test/.eslintrc.yml
@@ -0,0 +1,48 @@
+env:
+ es6: true
+ node: true
+ mocha: true
+extends: 'eslint:recommended'
+parserOptions:
+ ecmaVersion: 8
+ sourceType:
+ - script
+rules:
+ indent:
+ - error
+ - 4
+ linebreak-style:
+ - error
+ - unix
+ quotes:
+ - error
+ - single
+ semi:
+ - error
+ - always
+ no-unused-vars:
+ - error
+ - args: none
+ no-console: warn
+ curly: error
+ eqeqeq: error
+ no-throw-literal: error
+ strict: error
+ no-var: error
+ dot-notation: error
+ no-tabs: error
+ no-trailing-spaces: error
+ # no-use-before-define: error
+ no-useless-call: error
+ no-with: error
+ operator-linebreak: error
+ require-jsdoc:
+ - error
+ - require:
+ ClassDeclaration: true
+ MethodDefinition: true
+ FunctionDeclaration: true
+ valid-jsdoc:
+ - error
+ - requireReturn: false
+ yoda: error
diff --git a/packages/ergo-test/.gitignore b/packages/ergo-test/.gitignore
new file mode 100644
index 000000000..8bf8b5777
--- /dev/null
+++ b/packages/ergo-test/.gitignore
@@ -0,0 +1,7 @@
+*~
+.#*
+.DS_Store
+node_modules/
+log/
+.nyc_output
+coverage
diff --git a/packages/ergo-test/CHANGELOG.md b/packages/ergo-test/CHANGELOG.md
new file mode 100644
index 000000000..c05735ac3
--- /dev/null
+++ b/packages/ergo-test/CHANGELOG.md
@@ -0,0 +1,60 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+
+
+## [0.0.57](https://github.com/accordproject/ergo/compare/v0.0.48...v0.0.57) (2018-05-25)
+
+
+
+
+**Note:** Version bump only for package @accordproject/ergo-engine
+
+
+## [0.0.56](https://github.com/accordproject/ergo/compare/v0.0.48...v0.0.56) (2018-05-25)
+
+
+
+
+**Note:** Version bump only for package @accordproject/ergo-engine
+
+
+## [0.0.54](https://github.com/accordproject/ergo/compare/v0.0.48...v0.0.54) (2018-05-24)
+
+
+
+
+**Note:** Version bump only for package @accordproject/ergo-engine
+
+
+## [0.0.53](https://github.com/accordproject/ergo/compare/v0.0.52...v0.0.53) (2018-05-24)
+
+
+
+
+**Note:** Version bump only for package @accordproject/ergo-engine
+
+
+## [0.0.52](https://github.com/accordproject/ergo/compare/v0.0.48...v0.0.52) (2018-05-24)
+
+
+
+
+**Note:** Version bump only for package @accordproject/ergo-engine
+
+
+## [0.0.50](https://github.com/accordproject/ergo/compare/v0.0.49...v0.0.50) (2018-05-24)
+
+
+
+
+**Note:** Version bump only for package @accordproject/ergo-engine
+
+
+## [0.0.49](https://github.com/accordproject/ergo/compare/v0.0.48...v0.0.49) (2018-05-24)
+
+
+
+
+**Note:** Version bump only for package @accordproject/ergo-engine
diff --git a/packages/ergo-test/Makefile b/packages/ergo-test/Makefile
new file mode 100644
index 000000000..8f06b0d05
--- /dev/null
+++ b/packages/ergo-test/Makefile
@@ -0,0 +1,37 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+CP=cp
+
+## Top
+all:
+
+## Cleanup
+clean-npm:
+ - @rm -f package-lock.json
+ - @rm -rf dist
+
+cleanall-npm: clean-npm
+ - @rm -rf node_modules
+ - @rm -rf .nyc_output
+ - @rm -rf coverage
+ - @rm -rf log
+
+clean:
+ - @$(MAKE) clean-npm
+
+cleanall:
+ - @$(MAKE) cleanall-npm
+
diff --git a/packages/ergo-test/README.md b/packages/ergo-test/README.md
new file mode 100644
index 000000000..36bd93a56
--- /dev/null
+++ b/packages/ergo-test/README.md
@@ -0,0 +1,14 @@
+# Ergo Test
+
+Core classes for testing Ergo contract logic using Cucumber syntax
+
+## Installation
+
+```
+npm install @accordproject/ergo-test --save
+```
+
+## More information
+
+[Accord Project Documentation](https://docs.accordproject.org)
+
diff --git a/packages/ergo-test/header.txt b/packages/ergo-test/header.txt
new file mode 100644
index 000000000..e1971c44e
--- /dev/null
+++ b/packages/ergo-test/header.txt
@@ -0,0 +1,13 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
diff --git a/packages/ergo-test/index.js b/packages/ergo-test/index.js
new file mode 100644
index 000000000..ea044e35b
--- /dev/null
+++ b/packages/ergo-test/index.js
@@ -0,0 +1,23 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+/**
+ * Ergo Engine - execution for JavaScript target
+ * @module ergo-engine
+ */
+
+module.exports.Steps = require('./lib/steps.js');
+module.exports.Util = require('./lib/util.js');
diff --git a/packages/ergo-engine/lib/steps.js b/packages/ergo-test/lib/steps.js
similarity index 99%
rename from packages/ergo-engine/lib/steps.js
rename to packages/ergo-test/lib/steps.js
index ffa06803b..5033d7710 100644
--- a/packages/ergo-engine/lib/steps.js
+++ b/packages/ergo-test/lib/steps.js
@@ -21,7 +21,7 @@ const Chai = require('chai');
const expect = Chai.expect;
const TemplateLogic = require('@accordproject/ergo-compiler').TemplateLogic;
-const Engine = require('./engine');
+const Engine = require('@accordproject/ergo-engine').Engine;
const Util = require('./util');
const { Before, Given, When, Then } = require('cucumber');
diff --git a/packages/ergo-test/lib/util.js b/packages/ergo-test/lib/util.js
new file mode 100644
index 000000000..342d302e9
--- /dev/null
+++ b/packages/ergo-test/lib/util.js
@@ -0,0 +1,80 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+const Chai = require('chai');
+const expect = Chai.expect;
+
+/**
+ * Resolve the root directory
+ *
+ * @param {string} parameters Cucumber's World parameters
+ * @return {string} root directory used to resolve file names
+ */
+function resolveRootDir(parameters) {
+ if (parameters.rootdir) {
+ return parameters.rootdir;
+ } else {
+ return '.';
+ }
+}
+
+/**
+ * Compare actual and expected result components
+ *
+ * @param {string} expected the expected component as specified in the test workload
+ * @param {string} actual the actual component as returned by the engine
+ */
+function compareComponent(expected,actual) {
+ if (!expected) {
+ expect(actual).to.equal(expected);
+ } else {
+ delete expected.timestamp;
+ delete actual.timestamp;
+ // Some basic deep comparison for arrays, since Chai doesn't do the right thing
+ if (Array.isArray(actual)) {
+ for (let i = 0; i < expected.length; i++) {
+ delete expected[i].timestamp;
+ delete actual[i].timestamp;
+ expect(actual[i]).to.deep.include(expected[i]);
+ }
+ } else {
+ expect(actual).to.deep.include(expected);
+ }
+ }
+}
+
+/**
+ * Compare actual result and expected result
+ *
+ * @param {string} expected the expected successful result as specified in the test workload
+ * @param {string} actual the successful result as returned by the engine
+ */
+function compareSuccess(expected,actual) {
+ if (expected.hasOwnProperty('state')) {
+ expect(actual).to.have.property('state');
+ compareComponent(expected.state, actual.state);
+ }
+ if (expected.hasOwnProperty('response')) {
+ expect(actual).to.have.property('response');
+ compareComponent(expected.response, actual.response);
+ }
+ if (expected.hasOwnProperty('emit')) {
+ expect(actual).to.have.property('emit');
+ compareComponent(expected.emit, actual.emit);
+ }
+}
+
+module.exports = { resolveRootDir, compareComponent, compareSuccess };
diff --git a/packages/ergo-test/package.json b/packages/ergo-test/package.json
new file mode 100644
index 000000000..0acc1411d
--- /dev/null
+++ b/packages/ergo-test/package.json
@@ -0,0 +1,80 @@
+{
+ "name": "@accordproject/ergo-test",
+ "version": "0.7.3",
+ "description": "Ergo Test",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/accordproject/ergo"
+ },
+ "main": "index.js",
+ "scripts": {
+ "pretest": "npm run lint",
+ "lint": "eslint .",
+ "postlint": "npm run licchk",
+ "licchk": "license-check",
+ "test:cucumber": "cucumber-js test/features --require lib/steps.js --world-parameters '{\"rootdir\":\"./test\"}'",
+ "test:mocha": "mocha",
+ "test:all": "npm run test:mocha && npm run test:cucumber",
+ "test:cov": "nyc npm run test:all",
+ "test": "npm run test:all && npm run test:cov"
+ },
+ "contributors": [
+ {
+ "name": "Jerome Simeon",
+ "email": "jerome@clause.io"
+ }
+ ],
+ "license": "Apache-2.0",
+ "publishConfig": {
+ "access": "public"
+ },
+ "dependencies": {
+ "@accordproject/ergo-compiler": "0.7.3",
+ "@accordproject/ergo-engine": "0.7.3",
+ "chai": "4.2.0",
+ "chai-as-promised": "7.1.1",
+ "chai-things": "0.2.0",
+ "cucumber": "^5.1.0"
+ },
+ "devDependencies": {
+ "eslint": "4.19.1",
+ "jsdoc": "3.5.5",
+ "lerna": "2.11.0",
+ "license-check": "1.1.5",
+ "mocha": "5.2.0",
+ "nyc": "11.8.0"
+ },
+ "license-check-config": {
+ "src": [
+ "**/*.js",
+ "!./test/data/**/*",
+ "!./coverage/**/*",
+ "!./node_modules/**/*",
+ "!./out/**/*"
+ ],
+ "path": "header.txt",
+ "blocking": true,
+ "logInfo": false,
+ "logError": true
+ },
+ "nyc": {
+ "produce-source-map": "true",
+ "sourceMap": "inline",
+ "reporter": [
+ "lcov",
+ "text-summary",
+ "html",
+ "json"
+ ],
+ "include": [
+ "lib/**/*.js"
+ ],
+ "exclude": [],
+ "all": true,
+ "check-coverage": true,
+ "statements": 93,
+ "branches": 70,
+ "functions": 92,
+ "lines": 93
+ }
+}
\ No newline at end of file
diff --git a/packages/ergo-test/test/examples b/packages/ergo-test/test/examples
new file mode 120000
index 000000000..9f9d1de88
--- /dev/null
+++ b/packages/ergo-test/test/examples
@@ -0,0 +1 @@
+../../../examples
\ No newline at end of file
diff --git a/packages/ergo-engine/test/features/acceptanceofdelivery_normal.feature b/packages/ergo-test/test/features/acceptanceofdelivery_normal.feature
similarity index 100%
rename from packages/ergo-engine/test/features/acceptanceofdelivery_normal.feature
rename to packages/ergo-test/test/features/acceptanceofdelivery_normal.feature
diff --git a/packages/ergo-engine/test/features/badclause.feature b/packages/ergo-test/test/features/badclause.feature
similarity index 100%
rename from packages/ergo-engine/test/features/badclause.feature
rename to packages/ergo-test/test/features/badclause.feature
diff --git a/packages/ergo-engine/test/features/badfunction.feature b/packages/ergo-test/test/features/badfunction.feature
similarity index 100%
rename from packages/ergo-engine/test/features/badfunction.feature
rename to packages/ergo-test/test/features/badfunction.feature
diff --git a/packages/ergo-engine/test/features/badlogic.feature b/packages/ergo-test/test/features/badlogic.feature
similarity index 100%
rename from packages/ergo-engine/test/features/badlogic.feature
rename to packages/ergo-test/test/features/badlogic.feature
diff --git a/packages/ergo-engine/test/features/dispatchtest1.feature b/packages/ergo-test/test/features/dispatchtest1.feature
similarity index 100%
rename from packages/ergo-engine/test/features/dispatchtest1.feature
rename to packages/ergo-test/test/features/dispatchtest1.feature
diff --git a/packages/ergo-engine/test/features/dispatchtest2.feature b/packages/ergo-test/test/features/dispatchtest2.feature
similarity index 100%
rename from packages/ergo-engine/test/features/dispatchtest2.feature
rename to packages/ergo-test/test/features/dispatchtest2.feature
diff --git a/packages/ergo-engine/test/features/dispatchtest3.feature b/packages/ergo-test/test/features/dispatchtest3.feature
similarity index 100%
rename from packages/ergo-engine/test/features/dispatchtest3.feature
rename to packages/ergo-test/test/features/dispatchtest3.feature
diff --git a/packages/ergo-engine/test/features/fragilegoods_normal.feature b/packages/ergo-test/test/features/fragilegoods_normal.feature
similarity index 100%
rename from packages/ergo-engine/test/features/fragilegoods_normal.feature
rename to packages/ergo-test/test/features/fragilegoods_normal.feature
diff --git a/packages/ergo-engine/test/features/helloworld_betty.feature b/packages/ergo-test/test/features/helloworld_betty.feature
similarity index 100%
rename from packages/ergo-engine/test/features/helloworld_betty.feature
rename to packages/ergo-test/test/features/helloworld_betty.feature
diff --git a/packages/ergo-engine/test/features/helloworld_fred.feature b/packages/ergo-test/test/features/helloworld_fred.feature
similarity index 100%
rename from packages/ergo-engine/test/features/helloworld_fred.feature
rename to packages/ergo-test/test/features/helloworld_fred.feature
diff --git a/packages/ergo-engine/test/features/helloworld_fred_es5.feature b/packages/ergo-test/test/features/helloworld_fred_es5.feature
similarity index 100%
rename from packages/ergo-engine/test/features/helloworld_fred_es5.feature
rename to packages/ergo-test/test/features/helloworld_fred_es5.feature
diff --git a/packages/ergo-engine/test/features/inheritancetest.feature b/packages/ergo-test/test/features/inheritancetest.feature
similarity index 100%
rename from packages/ergo-engine/test/features/inheritancetest.feature
rename to packages/ergo-test/test/features/inheritancetest.feature
diff --git a/packages/ergo-engine/test/features/initemittest.feature b/packages/ergo-test/test/features/initemittest.feature
similarity index 100%
rename from packages/ergo-engine/test/features/initemittest.feature
rename to packages/ergo-test/test/features/initemittest.feature
diff --git a/packages/ergo-engine/test/features/initfailtest.feature b/packages/ergo-test/test/features/initfailtest.feature
similarity index 100%
rename from packages/ergo-engine/test/features/initfailtest.feature
rename to packages/ergo-test/test/features/initfailtest.feature
diff --git a/packages/ergo-engine/test/features/installmentsale_normal.feature b/packages/ergo-test/test/features/installmentsale_normal.feature
similarity index 100%
rename from packages/ergo-engine/test/features/installmentsale_normal.feature
rename to packages/ergo-test/test/features/installmentsale_normal.feature
diff --git a/packages/ergo-engine/test/features/integertest.feature b/packages/ergo-test/test/features/integertest.feature
similarity index 100%
rename from packages/ergo-engine/test/features/integertest.feature
rename to packages/ergo-test/test/features/integertest.feature
diff --git a/packages/ergo-engine/test/features/latedeliveryandpenalty_missing_cto.feature b/packages/ergo-test/test/features/latedeliveryandpenalty_missing_cto.feature
similarity index 100%
rename from packages/ergo-engine/test/features/latedeliveryandpenalty_missing_cto.feature
rename to packages/ergo-test/test/features/latedeliveryandpenalty_missing_cto.feature
diff --git a/packages/ergo-engine/test/features/latedeliveryandpenalty_normal.feature b/packages/ergo-test/test/features/latedeliveryandpenalty_normal.feature
similarity index 100%
rename from packages/ergo-engine/test/features/latedeliveryandpenalty_normal.feature
rename to packages/ergo-test/test/features/latedeliveryandpenalty_normal.feature
diff --git a/packages/ergo-engine/test/features/promissorynote_simple.feature b/packages/ergo-test/test/features/promissorynote_simple.feature
similarity index 100%
rename from packages/ergo-engine/test/features/promissorynote_simple.feature
rename to packages/ergo-test/test/features/promissorynote_simple.feature
diff --git a/packages/ergo-engine/test/features/promissorynote_with_concept_model.feature b/packages/ergo-test/test/features/promissorynote_with_concept_model.feature
similarity index 100%
rename from packages/ergo-engine/test/features/promissorynote_with_concept_model.feature
rename to packages/ergo-test/test/features/promissorynote_with_concept_model.feature
diff --git a/packages/ergo-engine/test/features/promissorynote_with_module.feature b/packages/ergo-test/test/features/promissorynote_with_module.feature
similarity index 100%
rename from packages/ergo-engine/test/features/promissorynote_with_module.feature
rename to packages/ergo-test/test/features/promissorynote_with_module.feature
diff --git a/packages/ergo-engine/test/features/shadowingtest.feature b/packages/ergo-test/test/features/shadowingtest.feature
similarity index 100%
rename from packages/ergo-engine/test/features/shadowingtest.feature
rename to packages/ergo-test/test/features/shadowingtest.feature
diff --git a/packages/ergo-engine/test/features/startendtest.feature b/packages/ergo-test/test/features/startendtest.feature
similarity index 100%
rename from packages/ergo-engine/test/features/startendtest.feature
rename to packages/ergo-test/test/features/startendtest.feature
diff --git a/packages/ergo-engine/test/features/volumediscount_simple.feature b/packages/ergo-test/test/features/volumediscount_simple.feature
similarity index 100%
rename from packages/ergo-engine/test/features/volumediscount_simple.feature
rename to packages/ergo-test/test/features/volumediscount_simple.feature
diff --git a/packages/ergo-engine/test/features/volumediscount_with_fee.feature b/packages/ergo-test/test/features/volumediscount_with_fee.feature
similarity index 100%
rename from packages/ergo-engine/test/features/volumediscount_with_fee.feature
rename to packages/ergo-test/test/features/volumediscount_with_fee.feature
diff --git a/packages/ergo-engine/test/features/volumediscount_with_fee_match.feature b/packages/ergo-test/test/features/volumediscount_with_fee_match.feature
similarity index 100%
rename from packages/ergo-engine/test/features/volumediscount_with_fee_match.feature
rename to packages/ergo-test/test/features/volumediscount_with_fee_match.feature
diff --git a/packages/ergo-engine/test/features/volumediscount_with_let.feature b/packages/ergo-test/test/features/volumediscount_with_let.feature
similarity index 100%
rename from packages/ergo-engine/test/features/volumediscount_with_let.feature
rename to packages/ergo-test/test/features/volumediscount_with_let.feature
diff --git a/packages/ergo-test/test/util.js b/packages/ergo-test/test/util.js
new file mode 100644
index 000000000..f419caebd
--- /dev/null
+++ b/packages/ergo-test/test/util.js
@@ -0,0 +1,49 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+const Util = require('../lib/util');
+
+const chai = require('chai');
+
+chai.should();
+chai.use(require('chai-things'));
+chai.use(require('chai-as-promised'));
+
+describe('Resolve root directory for Cucumber', () => {
+ it('Should resolve to given root directory', function () {
+ return Util.resolveRootDir({rootdir:'foo/bar'}).should.equal('foo/bar');
+ });
+ it('Should resolve to \'.\'', function () {
+ return Util.resolveRootDir({}).should.equal('.');
+ });
+});
+describe('Compare components corner cases', () => {
+ it('Should succeed comparing null against null', function () {
+ return (() => Util.compareComponent(null, null)).should.not.throw;
+ });
+ it('Should fail comparing null against null', function () {
+ return (() => Util.compareComponent(null, 1)).should.throw('expected 1 to equal null');
+ });
+ it('Should succeed comparing undefined against undefined', function () {
+ return (() => Util.compareComponent(undefined, undefined)).should.not.throw;
+ });
+ it('Should fail comparing null against undefined', function () {
+ return (() => Util.compareComponent(null, undefined)).should.throw('expected undefined to equal null');
+ });
+ it('Should resolve to \'.\'', function () {
+ return Util.resolveRootDir({}).should.equal('.');
+ });
+});