mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-07 14:40:55 +03:00
Begin implementing a reporting mechanism
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -6,7 +6,7 @@ const storage = {
|
||||
length: sinon.stub()
|
||||
};
|
||||
|
||||
function request(id, meta) {
|
||||
function request(id, meta = {}) {
|
||||
return {
|
||||
params: { id },
|
||||
meta
|
||||
|
||||
@@ -133,7 +133,12 @@ describe('Storage', function() {
|
||||
};
|
||||
await storage.set('x', null, m);
|
||||
const meta = await storage.metadata('x');
|
||||
assert.deepEqual(meta, m);
|
||||
assert.deepEqual(meta, {
|
||||
...m,
|
||||
dead: false,
|
||||
flagged: false,
|
||||
key: undefined
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user