Begin implementing a reporting mechanism

This commit is contained in:
Danny Coates 2020-07-13 10:21:28 -07:00
parent ccbcb69666
commit 9891d1f0ba
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
37 changed files with 762 additions and 183 deletions

View file

@ -2,7 +2,7 @@ const sinon = require('sinon');
const proxyquire = require('proxyquire').noCallThru();
const storage = {
del: sinon.stub(),
kill: sinon.stub(),
ttl: sinon.stub()
};
@ -24,19 +24,19 @@ const delRoute = proxyquire('../../server/routes/delete', {
describe('/api/delete', function() {
afterEach(function() {
storage.del.reset();
storage.kill.reset();
});
it('calls storage.del with the id parameter', async function() {
it('calls storage.kill with the id parameter', async function() {
const req = request('x');
const res = response();
await delRoute(req, res);
sinon.assert.calledWith(storage.del, 'x');
sinon.assert.calledWith(storage.kill, 'x');
sinon.assert.calledWith(res.sendStatus, 200);
});
it('sends a 404 on failure', async function() {
storage.del.returns(Promise.reject(new Error()));
storage.kill.returns(Promise.reject(new Error()));
const res = response();
await delRoute(request('x'), res);
sinon.assert.calledWith(res.sendStatus, 404);