mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 09:32:41 +00:00
Resolve "Transition to ESLint"
This commit is contained in:
committed by
Rainer Killinger
parent
ca1d2444e0
commit
418ba67d15
@@ -16,8 +16,11 @@
|
||||
import {
|
||||
SCNotFoundErrorResponse,
|
||||
SCPluginAdd,
|
||||
SCPluginAlreadyRegisteredErrorResponse, SCPluginRegisterResponse, SCPluginRegisterRoute,
|
||||
SCPluginRemove, SCValidationErrorResponse,
|
||||
SCPluginAlreadyRegisteredErrorResponse,
|
||||
SCPluginRegisterResponse,
|
||||
SCPluginRegisterRoute,
|
||||
SCPluginRemove,
|
||||
SCValidationErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import nock from 'nock';
|
||||
import {configFile, plugins} from '../../src/common';
|
||||
@@ -36,7 +39,7 @@ export const registerAddRequest: SCPluginAdd = registerRequest as SCPluginAdd;
|
||||
|
||||
export const registerRemoveRequest: SCPluginRemove = {
|
||||
action: 'remove',
|
||||
route: registerAddRequest.plugin.route
|
||||
route: registerAddRequest.plugin.route,
|
||||
};
|
||||
|
||||
describe('Plugin registration', async function () {
|
||||
@@ -52,9 +55,9 @@ describe('Plugin registration', async function () {
|
||||
// register one plugin
|
||||
const response = await pluginRegisterHandler(registerAddRequest, {});
|
||||
|
||||
expect(response).to.deep.equal(bodySuccess)
|
||||
&& expect(plugins.size).to.equal(1)
|
||||
&& expect(configFile.app.features.plugins!['Foo Plugin']).to.not.be.empty;
|
||||
expect(response).to.deep.equal(bodySuccess) &&
|
||||
expect(plugins.size).to.equal(1) &&
|
||||
expect(configFile.app.features.plugins!['Foo Plugin']).to.not.be.empty;
|
||||
});
|
||||
|
||||
it('should allow re-registering the same plugin', async function () {
|
||||
@@ -64,9 +67,11 @@ describe('Plugin registration', async function () {
|
||||
// register the same plugin again
|
||||
const response = await pluginRegisterHandler(registerAddRequest, {});
|
||||
|
||||
return expect(response).to.deep.equal(bodySuccess)
|
||||
&& expect(plugins.size).to.equal(1)
|
||||
&& expect(configFile.app.features.plugins!['Foo Plugin']).to.not.be.empty;
|
||||
return (
|
||||
expect(response).to.deep.equal(bodySuccess) &&
|
||||
expect(plugins.size).to.equal(1) &&
|
||||
expect(configFile.app.features.plugins!['Foo Plugin']).to.not.be.empty
|
||||
);
|
||||
});
|
||||
|
||||
it('should show an error if a plugin has already been registered', async function () {
|
||||
@@ -74,9 +79,9 @@ describe('Plugin registration', async function () {
|
||||
await pluginRegisterHandler(registerAddRequest, {});
|
||||
|
||||
// create new request for adding a plugin with only name that changed
|
||||
let registerAddRequestAltered: SCPluginAdd = {
|
||||
const registerAddRequestAltered: SCPluginAdd = {
|
||||
...registerAddRequest,
|
||||
plugin: {...registerAddRequest.plugin, name: registerAddRequest.plugin.name + 'foo'}
|
||||
plugin: {...registerAddRequest.plugin, name: registerAddRequest.plugin.name + 'foo'},
|
||||
};
|
||||
|
||||
// register the same plugin again
|
||||
@@ -95,9 +100,9 @@ describe('Plugin registration', async function () {
|
||||
|
||||
const response = await pluginRegisterHandler(registerRemoveRequest, {});
|
||||
|
||||
expect(response).to.deep.equal(bodySuccess)
|
||||
&& expect(plugins.size).to.equal(0)
|
||||
&& expect(configFile.app.features.plugins).to.be.empty;
|
||||
expect(response).to.deep.equal(bodySuccess) &&
|
||||
expect(plugins.size).to.equal(0) &&
|
||||
expect(configFile.app.features.plugins).to.be.empty;
|
||||
});
|
||||
|
||||
it('should throw a "not found" error when removing a plugin whose registered route does not exist', async function () {
|
||||
@@ -116,10 +121,10 @@ describe('Plugin registration', async function () {
|
||||
const pluginRegisterRoute = new SCPluginRegisterRoute();
|
||||
const validationError = new SCValidationErrorResponse([]);
|
||||
const notFoundError = new SCNotFoundErrorResponse();
|
||||
//@ts-ignore
|
||||
// @ts-expect-error not assignable
|
||||
const alreadyRegisteredError = new SCPluginAlreadyRegisteredErrorResponse('Foo Message', {});
|
||||
|
||||
afterEach(async function() {
|
||||
afterEach(async function () {
|
||||
// remove routes
|
||||
plugins.clear();
|
||||
// clean up request mocks (fixes issue with receiving response from mock from previous test case)
|
||||
@@ -157,7 +162,10 @@ describe('Plugin registration', async function () {
|
||||
// lets simulate that a plugin is already registered
|
||||
plugins.set(registerAddRequest.plugin.route, registerAddRequest.plugin);
|
||||
// registering a different plugin for the same route causes the expected error
|
||||
const registerAddRequestAltered = {...registerAddRequest, plugin: {...registerAddRequest.plugin, name: 'FooBar Plugin'}};
|
||||
const registerAddRequestAltered = {
|
||||
...registerAddRequest,
|
||||
plugin: {...registerAddRequest.plugin, name: 'FooBar Plugin'},
|
||||
};
|
||||
|
||||
const {status, body} = await testApp
|
||||
.post(pluginRegisterRoute.urlPath)
|
||||
@@ -169,7 +177,7 @@ describe('Plugin registration', async function () {
|
||||
expect(body).to.haveOwnProperty('name', 'SCPluginAlreadyRegisteredError');
|
||||
});
|
||||
|
||||
it('should respond with success when de-registering already registered plugin', async function() {
|
||||
it('should respond with success when de-registering already registered plugin', async function () {
|
||||
// lets simulate that a plugin is already registered
|
||||
plugins.set(registerAddRequest.plugin.route, registerAddRequest.plugin);
|
||||
|
||||
@@ -183,7 +191,7 @@ describe('Plugin registration', async function () {
|
||||
expect(body).to.be.deep.equal(bodySuccess);
|
||||
});
|
||||
|
||||
it('should response with 404 when deleting a plugin which was not registered', async function() {
|
||||
it('should response with 404 when deleting a plugin which was not registered', async function () {
|
||||
// lets simulate that the plugin is already registered
|
||||
plugins.set(registerAddRequest.plugin.route, registerAddRequest.plugin);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user