swish-test-suite

0.3.2 • Public • Published

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 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.

Suite format

A suite is an object with the following properties:

  • name - a string
  • tests - 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);
			});
		});
	});
});

Readme

Keywords

none

Package Sidebar

Install

npm i swish-test-suite

Weekly Downloads

1

Version

0.3.2

License

MIT

Last publish

Collaborators

  • geraintluff