This module provides generic tests for the implementation of custom TokenStores for Passwordless, a node.js module for express that allows website authentication without password using verification through email or other means.
In the folder of your custom TokenStore implementation do:
$ npm install passwordless-tokenstore-test --save-dev
Afterwards, you can simply call the test suite as part of your other tests. For example:
var standardTests = require('passwordless-tokenstore-test');
function TokenStoreFactory() {
return new YourTokenStore();
}
var beforeEachTest = function(done) {
// clean database before usage
done();
}
var afterEachTest = function(done) {
// any other activity after each test
done();
}
// Call the test suite
standardTests(TokenStoreFactory, beforeEachTest, afterEachTest);
describe('Your specific tests', function() {
beforeEach(function(done) {
beforeEachTest(done);
})
afterEach(function(done) {
afterEachTest(done);
})
it('should...', function () {
expect(...).to...
})
})
The exported function has to be called with the following parameter:
standardTests(TokenStoreFactory(), beforeEachTest(done), afterEachTest(done), [timeout]);
All parameters are mandatory.
The test suite expects a clean state of the TokenStore (incl. the underlying database) for each test. You may use beforeEachTest to clean the state of the database.
Florian Heinemann @thesumofall