test: remove tokendb from users-test

This commit is contained in:
Girish Ramakrishnan
2021-06-05 11:46:34 -07:00
parent 9c49ca5d2e
commit fe8358c3e3
4 changed files with 524 additions and 867 deletions

View File

@@ -3,7 +3,9 @@
const async = require('async'),
constants = require('../../constants.js'),
database = require('../../database.js'),
delay = require('delay'),
expect = require('expect.js'),
mailer = require('../../mailer.js'),
server = require('../../server.js'),
settings = require('../../settings.js'),
superagent = require('superagent'),
@@ -12,6 +14,8 @@ const async = require('async'),
exports = module.exports = {
setup,
cleanup,
clearMailQueue,
checkMails,
owner: {
id: null,
@@ -33,7 +37,7 @@ exports = module.exports = {
DASHBOARD_DOMAIN: 'test.example.com',
DASHBOARD_FQDN: 'my.test.example.com',
serverUrl: `http://localhost:${constants.PORT}`
serverUrl: `http://localhost:${constants.PORT}`,
};
function setup(done) {
@@ -71,7 +75,6 @@ function setup(done) {
expect(result.statusCode).to.equal(201);
user.id = result.body.id;
user.token = 'usertoken';
// HACK to get a token for second user (passwords are generated and the user should have gotten a password setup link...)
const token = await tokens.add({ identifier: user.id, clientId: 'test-client-id', expires: Date.now() + 10000, name: 'fromtest' });
@@ -90,3 +93,13 @@ function cleanup(done) {
server.stop(done);
});
}
function clearMailQueue() {
mailer._mailQueue = [];
}
async function checkMails(number) {
await delay(1000);
expect(mailer._mailQueue.length).to.equal(number);
clearMailQueue();
}