swish-test-suite
v0.3.2
Published
Standard tests for the Swish API
Downloads
2
Readme
Swish API test suites
This 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.
Usage
To get a list of tests:
swishTests.tests()
To get a list of suites, each containing a list of tests:
swishTests.suites()
Test format
Each test is an object with the following properties:
name
- a stringschema
- a JSON Schema which all data items used in the test followrun
- a function taking two arguments:store
anddone
.
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
.
Suite format
A suite is an object with the following properties:
name
- a stringtests
- an array of tests (in the above format)
Use with Mocha
Here is an example of how you might use this package within a Mocha test file to test your implementation:
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);
});
});
});
});