Standard tests for the Swish API
npm install swish-test-suiteThis package provides some tests for the Swish API.
It includes some tests from the JSON Schema Test Suite, but does not include this as a dependency.
All tests are compiled into index.js, to allow simpler testing in browsers.
To get a list of tests:
``javascript`
swishTests.tests()
To get a list of suites, each containing a list of tests:
`javascript`
swishTests.suites()
Each test is an object with the following properties:
* name - a string
* schema - a JSON Schema which all data items used in the test follow
* run - a function taking two arguments: store and done.
A fresh/empty store should be provided to each test.
To run the test, call .run(). When the test is finished, done() will be called, and the first argument will be either an error or null.
A suite is an object with the following properties:
* name - a string
* tests - an array of tests (in the above format)
Here is an example of how you might use this package within a Mocha test file to test your implementation:
`javascript
var swishTests = require('swish-test-suite');
swishTests.suites().forEach(function (suite) {
describe(suite.name, function () {
suite.tests.forEach(function (test) {
it(test.name, function (done) {
// Set up the store
var store = new MyImplementation(config, test.schema);
test.run(store, done);
});
});
});
});
``