Use arrow functions in mocha tests
This commit is contained in:
parent
c8db7388c3
commit
5c675474d7
@ -17,9 +17,9 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
app = yield init();
|
app = yield init();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('REST api', function() {
|
describe('REST api', () => {
|
||||||
describe('POST /api/v1/key', function() {
|
describe('POST /api/v1/key', () => {
|
||||||
it('should return 400 for an invalid body', function (done) {
|
it('should return 400 for an invalid body', done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/api/v1/key')
|
.post('/api/v1/key')
|
||||||
.send({ foo: 'bar' })
|
.send({ foo: 'bar' })
|
||||||
@ -29,16 +29,16 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('HKP api', function() {
|
describe('HKP api', () => {
|
||||||
describe('GET /pks/add', function() {
|
describe('GET /pks/add', () => {
|
||||||
it.skip('should return 200 for a valid request', function (done) {
|
it.skip('should return 200 for a valid request', done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.get('/pks/lookup?op=get&search=0xDBC0B3D92B1B86E9')
|
.get('/pks/lookup?op=get&search=0xDBC0B3D92B1B86E9')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return 404 if not found', function (done) {
|
it('should return 404 if not found', done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.get('/pks/lookup?op=get&search=0xDBC0B3D92A1B86E9')
|
.get('/pks/lookup?op=get&search=0xDBC0B3D92A1B86E9')
|
||||||
.expect(404)
|
.expect(404)
|
||||||
@ -46,8 +46,8 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('POST /pks/add', function() {
|
describe('POST /pks/add', () => {
|
||||||
it('should return 400 for an invalid body', function (done) {
|
it('should return 400 for an invalid body', done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/pks/add')
|
.post('/pks/add')
|
||||||
.type('form')
|
.type('form')
|
||||||
@ -56,7 +56,7 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return 201 for a valid PGP key', function (done) {
|
it('should return 201 for a valid PGP key', done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/pks/add')
|
.post('/pks/add')
|
||||||
.type('form')
|
.type('form')
|
||||||
|
@ -15,7 +15,7 @@ describe('Email Integration Tests', function() {
|
|||||||
|
|
||||||
let email, credentials;
|
let email, credentials;
|
||||||
|
|
||||||
before(function() {
|
before(() => {
|
||||||
try {
|
try {
|
||||||
credentials = require('../../credentials.json');
|
credentials = require('../../credentials.json');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@ -37,7 +37,7 @@ describe('Email Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("send", function() {
|
describe("send", () => {
|
||||||
it('should work', function *() {
|
it('should work', function *() {
|
||||||
let mailOptions = {
|
let mailOptions = {
|
||||||
from: credentials.sender,
|
from: credentials.sender,
|
||||||
@ -51,7 +51,7 @@ describe('Email Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("sendVerifyKey", function() {
|
describe("sendVerifyKey", () => {
|
||||||
it('should work', function *() {
|
it('should work', function *() {
|
||||||
let options = {
|
let options = {
|
||||||
userIds: [{
|
userIds: [{
|
||||||
|
@ -31,14 +31,12 @@ describe('Mongo Integration Tests', function() {
|
|||||||
yield mongo.clear(DB_TYPE);
|
yield mongo.clear(DB_TYPE);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {});
|
|
||||||
|
|
||||||
after(function *() {
|
after(function *() {
|
||||||
yield mongo.clear(DB_TYPE);
|
yield mongo.clear(DB_TYPE);
|
||||||
yield mongo.disconnect();
|
yield mongo.disconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("create", function() {
|
describe("create", () => {
|
||||||
it('should insert a document', function *() {
|
it('should insert a document', function *() {
|
||||||
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
||||||
expect(r.insertedCount).to.equal(1);
|
expect(r.insertedCount).to.equal(1);
|
||||||
@ -55,7 +53,7 @@ describe('Mongo Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("batch", function() {
|
describe("batch", () => {
|
||||||
it('should insert a document', function *() {
|
it('should insert a document', function *() {
|
||||||
let r = yield mongo.batch([{ _id:'0' }, { _id:'1' }], DB_TYPE);
|
let r = yield mongo.batch([{ _id:'0' }, { _id:'1' }], DB_TYPE);
|
||||||
expect(r.insertedCount).to.equal(2);
|
expect(r.insertedCount).to.equal(2);
|
||||||
@ -72,7 +70,7 @@ describe('Mongo Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("update", function() {
|
describe("update", () => {
|
||||||
it('should update a document', function *() {
|
it('should update a document', function *() {
|
||||||
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
||||||
r = yield mongo.update({ _id:'0' }, { foo:'bar' }, DB_TYPE);
|
r = yield mongo.update({ _id:'0' }, { foo:'bar' }, DB_TYPE);
|
||||||
@ -82,7 +80,7 @@ describe('Mongo Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("get", function() {
|
describe("get", () => {
|
||||||
it('should get a document', function *() {
|
it('should get a document', function *() {
|
||||||
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
||||||
r = yield mongo.get({ _id:'0' }, DB_TYPE);
|
r = yield mongo.get({ _id:'0' }, DB_TYPE);
|
||||||
@ -90,7 +88,7 @@ describe('Mongo Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("list", function() {
|
describe("list", () => {
|
||||||
it('should list documents', function *() {
|
it('should list documents', function *() {
|
||||||
let r = yield mongo.batch([{ _id:'0', foo:'bar' }, { _id:'1', foo:'bar' }], DB_TYPE);
|
let r = yield mongo.batch([{ _id:'0', foo:'bar' }, { _id:'1', foo:'bar' }], DB_TYPE);
|
||||||
r = yield mongo.list({ foo:'bar' }, DB_TYPE);
|
r = yield mongo.list({ foo:'bar' }, DB_TYPE);
|
||||||
@ -98,7 +96,7 @@ describe('Mongo Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("remove", function() {
|
describe("remove", () => {
|
||||||
it('should remove a document', function *() {
|
it('should remove a document', function *() {
|
||||||
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
|
||||||
r = yield mongo.remove({ _id:'0' }, DB_TYPE);
|
r = yield mongo.remove({ _id:'0' }, DB_TYPE);
|
||||||
|
@ -42,14 +42,12 @@ describe('User ID Integration Tests', function() {
|
|||||||
yield mongo.clear(DB_TYPE);
|
yield mongo.clear(DB_TYPE);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {});
|
|
||||||
|
|
||||||
after(function *() {
|
after(function *() {
|
||||||
yield mongo.clear(DB_TYPE);
|
yield mongo.clear(DB_TYPE);
|
||||||
yield mongo.disconnect();
|
yield mongo.disconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("batch", function() {
|
describe("batch", () => {
|
||||||
it('should persist all the things', function *() {
|
it('should persist all the things', function *() {
|
||||||
let uids = yield userId.batch({ userIds:[uid1, uid2], keyid });
|
let uids = yield userId.batch({ userIds:[uid1, uid2], keyid });
|
||||||
expect(uids[0].keyid).to.equal(keyid);
|
expect(uids[0].keyid).to.equal(keyid);
|
||||||
@ -63,7 +61,7 @@ describe('User ID Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("verify", function() {
|
describe("verify", () => {
|
||||||
it('should update the document', function *() {
|
it('should update the document', function *() {
|
||||||
let uids = yield userId.batch({ userIds:[uid1], keyid });
|
let uids = yield userId.batch({ userIds:[uid1], keyid });
|
||||||
yield userId.verify({ keyid, nonce:uids[0].nonce });
|
yield userId.verify({ keyid, nonce:uids[0].nonce });
|
||||||
@ -85,7 +83,7 @@ describe('User ID Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getVerfied", function() {
|
describe("getVerfied", () => {
|
||||||
beforeEach(function *() {
|
beforeEach(function *() {
|
||||||
let uids = yield userId.batch({ userIds:[uid1], keyid });
|
let uids = yield userId.batch({ userIds:[uid1], keyid });
|
||||||
yield userId.verify({ keyid, nonce:uids[0].nonce });
|
yield userId.verify({ keyid, nonce:uids[0].nonce });
|
||||||
@ -102,7 +100,7 @@ describe('User ID Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("flagForRemove", function() {
|
describe("flagForRemove", () => {
|
||||||
it('should flag all documents', function *() {
|
it('should flag all documents', function *() {
|
||||||
let stored = yield userId.batch({ userIds:[uid1, uid2], keyid });
|
let stored = yield userId.batch({ userIds:[uid1, uid2], keyid });
|
||||||
let flagged = yield userId.flagForRemove({ keyid });
|
let flagged = yield userId.flagForRemove({ keyid });
|
||||||
@ -113,7 +111,7 @@ describe('User ID Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("remove", function() {
|
describe("remove", () => {
|
||||||
it('should delete all documents', function *() {
|
it('should delete all documents', function *() {
|
||||||
yield userId.batch({ userIds:[uid1, uid2], keyid });
|
yield userId.batch({ userIds:[uid1, uid2], keyid });
|
||||||
yield userId.remove({ keyid });
|
yield userId.remove({ keyid });
|
||||||
|
@ -9,7 +9,7 @@ const nodemailer = require('nodemailer');
|
|||||||
const sinon = require('sinon');
|
const sinon = require('sinon');
|
||||||
|
|
||||||
|
|
||||||
describe('Email Unit Tests', function() {
|
describe('Email Unit Tests', () => {
|
||||||
let email, sendFnStub;
|
let email, sendFnStub;
|
||||||
|
|
||||||
let sender = {
|
let sender = {
|
||||||
@ -40,10 +40,10 @@ describe('Email Unit Tests', function() {
|
|||||||
html: '<b>Hello world 🐴</b>' // html body
|
html: '<b>Hello world 🐴</b>' // html body
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(() => {
|
||||||
sendFnStub = sinon.stub();
|
sendFnStub = sinon.stub();
|
||||||
sinon.stub(nodemailer, 'createTransport').returns({
|
sinon.stub(nodemailer, 'createTransport').returns({
|
||||||
templateSender: function() { return sendFnStub; }
|
templateSender: () => { return sendFnStub; }
|
||||||
});
|
});
|
||||||
|
|
||||||
sinon.stub(log, 'warn');
|
sinon.stub(log, 'warn');
|
||||||
@ -58,19 +58,19 @@ describe('Email Unit Tests', function() {
|
|||||||
expect(email._sender).to.equal(sender);
|
expect(email._sender).to.equal(sender);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(() => {
|
||||||
nodemailer.createTransport.restore();
|
nodemailer.createTransport.restore();
|
||||||
log.warn.restore();
|
log.warn.restore();
|
||||||
log.error.restore();
|
log.error.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("sendVerifyKey", function() {
|
describe("sendVerifyKey", () => {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(() => {
|
||||||
sinon.stub(email, '_sendVerifyKeyHelper').returns(Promise.resolve({ response:'250' }));
|
sinon.stub(email, '_sendVerifyKeyHelper').returns(Promise.resolve({ response:'250' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(() => {
|
||||||
email._sendVerifyKeyHelper.restore();
|
email._sendVerifyKeyHelper.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,12 +107,12 @@ describe('Email Unit Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("_sendVerifyKeyHelper", function() {
|
describe("_sendVerifyKeyHelper", () => {
|
||||||
beforeEach(function() {
|
beforeEach(() => {
|
||||||
sinon.stub(email, 'send').returns(Promise.resolve({ response:'250' }));
|
sinon.stub(email, 'send').returns(Promise.resolve({ response:'250' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(() => {
|
||||||
email.send.restore();
|
email.send.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -123,12 +123,12 @@ describe('Email Unit Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("sendVerifyRemove", function() {
|
describe("sendVerifyRemove", () => {
|
||||||
beforeEach(function() {
|
beforeEach(() => {
|
||||||
sinon.stub(email, 'send').returns(Promise.resolve({ response:'250' }));
|
sinon.stub(email, 'send').returns(Promise.resolve({ response:'250' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(() => {
|
||||||
email.send.restore();
|
email.send.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ describe('Email Unit Tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("send", function() {
|
describe("send", () => {
|
||||||
it('should work', function *() {
|
it('should work', function *() {
|
||||||
sendFnStub.returns(Promise.resolve({ response:'250' }));
|
sendFnStub.returns(Promise.resolve({ response:'250' }));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user