Use arrow functions in mocha tests

This commit is contained in:
Tankred Hase 2016-05-31 13:52:18 +02:00
parent c8db7388c3
commit 5c675474d7
5 changed files with 38 additions and 42 deletions

View File

@ -17,9 +17,9 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
app = yield init();
});
describe('REST api', function() {
describe('POST /api/v1/key', function() {
it('should return 400 for an invalid body', function (done) {
describe('REST api', () => {
describe('POST /api/v1/key', () => {
it('should return 400 for an invalid body', done => {
request(app.listen())
.post('/api/v1/key')
.send({ foo: 'bar' })
@ -29,16 +29,16 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
});
});
describe('HKP api', function() {
describe('GET /pks/add', function() {
it.skip('should return 200 for a valid request', function (done) {
describe('HKP api', () => {
describe('GET /pks/add', () => {
it.skip('should return 200 for a valid request', done => {
request(app.listen())
.get('/pks/lookup?op=get&search=0xDBC0B3D92B1B86E9')
.expect(200)
.end(done);
});
it('should return 404 if not found', function (done) {
it('should return 404 if not found', done => {
request(app.listen())
.get('/pks/lookup?op=get&search=0xDBC0B3D92A1B86E9')
.expect(404)
@ -46,8 +46,8 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
});
});
describe('POST /pks/add', function() {
it('should return 400 for an invalid body', function (done) {
describe('POST /pks/add', () => {
it('should return 400 for an invalid body', done => {
request(app.listen())
.post('/pks/add')
.type('form')
@ -56,7 +56,7 @@ describe.skip('Koa App (HTTP Server) Integration Tests', function() {
.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())
.post('/pks/add')
.type('form')

View File

@ -15,7 +15,7 @@ describe('Email Integration Tests', function() {
let email, credentials;
before(function() {
before(() => {
try {
credentials = require('../../credentials.json');
} catch(e) {
@ -37,7 +37,7 @@ describe('Email Integration Tests', function() {
});
});
describe("send", function() {
describe("send", () => {
it('should work', function *() {
let mailOptions = {
from: credentials.sender,
@ -51,7 +51,7 @@ describe('Email Integration Tests', function() {
});
});
describe("sendVerifyKey", function() {
describe("sendVerifyKey", () => {
it('should work', function *() {
let options = {
userIds: [{

View File

@ -31,14 +31,12 @@ describe('Mongo Integration Tests', function() {
yield mongo.clear(DB_TYPE);
});
afterEach(function() {});
after(function *() {
yield mongo.clear(DB_TYPE);
yield mongo.disconnect();
});
describe("create", function() {
describe("create", () => {
it('should insert a document', function *() {
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
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 *() {
let r = yield mongo.batch([{ _id:'0' }, { _id:'1' }], DB_TYPE);
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 *() {
let r = yield mongo.create({ _id:'0' }, 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 *() {
let r = yield mongo.create({ _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 *() {
let r = yield mongo.batch([{ _id:'0', foo:'bar' }, { _id:'1', 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 *() {
let r = yield mongo.create({ _id:'0' }, DB_TYPE);
r = yield mongo.remove({ _id:'0' }, DB_TYPE);

View File

@ -42,14 +42,12 @@ describe('User ID Integration Tests', function() {
yield mongo.clear(DB_TYPE);
});
afterEach(function() {});
after(function *() {
yield mongo.clear(DB_TYPE);
yield mongo.disconnect();
});
describe("batch", function() {
describe("batch", () => {
it('should persist all the things', function *() {
let uids = yield userId.batch({ userIds:[uid1, uid2], 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 *() {
let uids = yield userId.batch({ userIds:[uid1], keyid });
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 *() {
let uids = yield userId.batch({ userIds:[uid1], keyid });
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 *() {
let stored = yield userId.batch({ userIds:[uid1, uid2], 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 *() {
yield userId.batch({ userIds:[uid1, uid2], keyid });
yield userId.remove({ keyid });

View File

@ -9,7 +9,7 @@ const nodemailer = require('nodemailer');
const sinon = require('sinon');
describe('Email Unit Tests', function() {
describe('Email Unit Tests', () => {
let email, sendFnStub;
let sender = {
@ -40,10 +40,10 @@ describe('Email Unit Tests', function() {
html: '<b>Hello world 🐴</b>' // html body
};
beforeEach(function() {
beforeEach(() => {
sendFnStub = sinon.stub();
sinon.stub(nodemailer, 'createTransport').returns({
templateSender: function() { return sendFnStub; }
templateSender: () => { return sendFnStub; }
});
sinon.stub(log, 'warn');
@ -58,19 +58,19 @@ describe('Email Unit Tests', function() {
expect(email._sender).to.equal(sender);
});
afterEach(function() {
afterEach(() => {
nodemailer.createTransport.restore();
log.warn.restore();
log.error.restore();
});
describe("sendVerifyKey", function() {
describe("sendVerifyKey", () => {
beforeEach(function() {
beforeEach(() => {
sinon.stub(email, '_sendVerifyKeyHelper').returns(Promise.resolve({ response:'250' }));
});
afterEach(function() {
afterEach(() => {
email._sendVerifyKeyHelper.restore();
});
@ -107,12 +107,12 @@ describe('Email Unit Tests', function() {
});
});
describe("_sendVerifyKeyHelper", function() {
beforeEach(function() {
describe("_sendVerifyKeyHelper", () => {
beforeEach(() => {
sinon.stub(email, 'send').returns(Promise.resolve({ response:'250' }));
});
afterEach(function() {
afterEach(() => {
email.send.restore();
});
@ -123,12 +123,12 @@ describe('Email Unit Tests', function() {
});
});
describe("sendVerifyRemove", function() {
beforeEach(function() {
describe("sendVerifyRemove", () => {
beforeEach(() => {
sinon.stub(email, 'send').returns(Promise.resolve({ response:'250' }));
});
afterEach(function() {
afterEach(() => {
email.send.restore();
});
@ -139,7 +139,7 @@ describe('Email Unit Tests', function() {
});
});
describe("send", function() {
describe("send", () => {
it('should work', function *() {
sendFnStub.returns(Promise.resolve({ response:'250' }));