mirror of
https://github.com/timvisee/send.git
synced 2025-10-04 01:59:16 +02:00
Begin implementing a reporting mechanism
This commit is contained in:
parent
ccbcb69666
commit
9891d1f0ba
37 changed files with 762 additions and 183 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue