refactor: throw an error when removing a non-existing plugin

Related to #2
This commit is contained in:
Jovan Krunić
2019-07-05 15:25:42 +02:00
committed by Rainer Killinger
parent 992a0a6f2c
commit 3ea2c3b98d
3 changed files with 11 additions and 16 deletions

View File

@@ -17,6 +17,7 @@ import {
SCPluginAdd,
SCPluginAlreadyRegisteredErrorResponse,
SCPluginRemove,
SCNotFoundErrorResponse,
} from '@openstapps/core';
import {should, use} from 'chai';
import {slow, timeout} from 'mocha-typescript';
@@ -94,17 +95,12 @@ export class PluginRegisterRouteSpec {
}
@test
async 'should return false when removing a plugin whose route doesn\'t exist'() {
async 'should throw a "not found" error when removing a plugin whose route doesn\'t exist'() {
// register one plugin
await pluginRegisterHandler(registerAddRequest, {});
const response = await pluginRegisterHandler({...registerRemoveRequest, route: '/not-foo'}, {});
return response.should.eql({success: false});
// TODO: use 404 response
// return pluginRegisterHandler({...registerRemoveRequest, route: '/bar'}, {})
// .should.eventually.be.rejectedWith('Resource not found')
// .and.be.an.instanceOf(SCNotFoundErrorResponse);
return pluginRegisterHandler({...registerRemoveRequest, route: '/not-foo'}, {})
.should.eventually.be.rejectedWith('Resource not found')
.and.be.an.instanceOf(SCNotFoundErrorResponse);
}
}