mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 14:02:48 +00:00
refactor: remove legacy callbacks from bulk storage
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
import {expect, use} from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import {Request} from 'express';
|
||||
import got, { Options } from 'got';
|
||||
import got, {Options} from 'got';
|
||||
import nock from 'nock';
|
||||
import sinon from 'sinon';
|
||||
import {mockReq} from 'sinon-express-mock';
|
||||
@@ -79,9 +79,9 @@ describe('Virtual plugin routes', async function () {
|
||||
|
||||
await virtualPluginRoute(req, plugin);
|
||||
|
||||
expect(gotStub.args[0][0]).to.equal(plugin.route);
|
||||
expect(gotStub.args[0][0]).to.equal(plugin.route.substr(1));
|
||||
expect(((gotStub.args[0] as any)[1] as Options).prefixUrl).to.equal(plugin.address);
|
||||
expect(((gotStub.args[0] as any)[1] as Options).body).to.equal(req.body);
|
||||
expect(((gotStub.args[0] as any)[1] as Options).json).to.equal(req.body);
|
||||
});
|
||||
|
||||
it('should provide data from the plugin when its route is called', async function () {
|
||||
|
||||
@@ -81,14 +81,14 @@ describe('Bulk Storage', function () {
|
||||
});
|
||||
|
||||
it('should throw an error if the bulk for deletion cannot be read', async function () {
|
||||
sandbox.stub(BulkStorage.prototype, 'read').callsFake(async () => Promise.resolve(undefined));
|
||||
sandbox.stub(BulkStorage.prototype, 'read').callsFake(() => undefined);
|
||||
const bulkStorage = new BulkStorage(database);
|
||||
|
||||
return expect(bulkStorage.delete('123')).to.be.rejected;
|
||||
});
|
||||
|
||||
it('should delete a bulk', async function () {
|
||||
const readStub = sandbox.stub(BulkStorage.prototype, 'read').callsFake(async () => Promise.resolve(bulk));
|
||||
const readStub = sandbox.stub(BulkStorage.prototype, 'read').callsFake(() => bulk);
|
||||
let caught: any;
|
||||
sandbox.stub(NodeCache.prototype, 'del').callsFake(() => caught = 123);
|
||||
// force call
|
||||
|
||||
Reference in New Issue
Block a user