mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: update eslint settings
This commit is contained in:
@@ -2,10 +2,10 @@ import { AsyncHandler } from '../../../src/util/AsyncHandler';
|
||||
import { StaticAsyncHandler } from '../../util/StaticAsyncHandler';
|
||||
|
||||
describe('An AsyncHandler', (): void => {
|
||||
it('calls canHandle and handle when handleSafe is called.', async (): Promise<void> => {
|
||||
it('calls canHandle and handle when handleSafe is called.', async(): Promise<void> => {
|
||||
const handlerTrue: AsyncHandler<any, any> = new StaticAsyncHandler(true, null);
|
||||
const canHandleFn = jest.fn(async (input: any): Promise<void> => input);
|
||||
const handleFn = jest.fn(async (input: any): Promise<any> => input);
|
||||
const canHandleFn = jest.fn(async(input: any): Promise<void> => input);
|
||||
const handleFn = jest.fn(async(input: any): Promise<any> => input);
|
||||
|
||||
handlerTrue.canHandle = canHandleFn;
|
||||
handlerTrue.handle = handleFn;
|
||||
@@ -14,12 +14,12 @@ describe('An AsyncHandler', (): void => {
|
||||
expect(handleFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('does not call handle when canHandle errors during a handleSafe call.', async (): Promise<void> => {
|
||||
it('does not call handle when canHandle errors during a handleSafe call.', async(): Promise<void> => {
|
||||
const handlerFalse: AsyncHandler<any, any> = new StaticAsyncHandler(false, null);
|
||||
const canHandleFn = jest.fn(async (): Promise<void> => {
|
||||
const canHandleFn = jest.fn(async(): Promise<void> => {
|
||||
throw new Error('test');
|
||||
});
|
||||
const handleFn = jest.fn(async (input: any): Promise<any> => input);
|
||||
const handleFn = jest.fn(async(input: any): Promise<any> => input);
|
||||
|
||||
handlerFalse.canHandle = canHandleFn;
|
||||
handlerFalse.handle = handleFn;
|
||||
|
||||
@@ -4,13 +4,13 @@ import { StaticAsyncHandler } from '../../util/StaticAsyncHandler';
|
||||
|
||||
describe('A CompositeAsyncHandler', (): void => {
|
||||
describe('with no handlers', (): void => {
|
||||
it('can never handle data.', async (): Promise<void> => {
|
||||
it('can never handle data.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([]);
|
||||
|
||||
await expect(handler.canHandle(null)).rejects.toThrow(Error);
|
||||
});
|
||||
|
||||
it('errors if its handle function is called.', async (): Promise<void> => {
|
||||
it('errors if its handle function is called.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([]);
|
||||
|
||||
await expect(handler.handle(null)).rejects.toThrow(Error);
|
||||
@@ -23,29 +23,29 @@ describe('A CompositeAsyncHandler', (): void => {
|
||||
let canHandleFn: jest.Mock<Promise<void>, [any]>;
|
||||
let handleFn: jest.Mock<Promise<void>, [any]>;
|
||||
|
||||
beforeEach(async (): Promise<void> => {
|
||||
beforeEach(async(): Promise<void> => {
|
||||
handlerTrue = new StaticAsyncHandler(true, null);
|
||||
handlerFalse = new StaticAsyncHandler(false, null);
|
||||
|
||||
canHandleFn = jest.fn(async (input: any): Promise<any> => input);
|
||||
handleFn = jest.fn(async (input: any): Promise<any> => input);
|
||||
canHandleFn = jest.fn(async(input: any): Promise<any> => input);
|
||||
handleFn = jest.fn(async(input: any): Promise<any> => input);
|
||||
handlerTrue.canHandle = canHandleFn;
|
||||
handlerTrue.handle = handleFn;
|
||||
});
|
||||
|
||||
it('can handle data if a handler supports it.', async (): Promise<void> => {
|
||||
it('can handle data if a handler supports it.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([ handlerFalse, handlerTrue ]);
|
||||
|
||||
await expect(handler.canHandle(null)).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('can not handle data if no handler supports it.', async (): Promise<void> => {
|
||||
it('can not handle data if no handler supports it.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([ handlerFalse, handlerFalse ]);
|
||||
|
||||
await expect(handler.canHandle(null)).rejects.toThrow('[Not supported., Not supported.]');
|
||||
});
|
||||
|
||||
it('handles data if a handler supports it.', async (): Promise<void> => {
|
||||
it('handles data if a handler supports it.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([ handlerFalse, handlerTrue ]);
|
||||
|
||||
await expect(handler.handle('test')).resolves.toEqual('test');
|
||||
@@ -53,13 +53,13 @@ describe('A CompositeAsyncHandler', (): void => {
|
||||
expect(handleFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('errors if the handle function is called but no handler supports the data.', async (): Promise<void> => {
|
||||
it('errors if the handle function is called but no handler supports the data.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([ handlerFalse, handlerFalse ]);
|
||||
|
||||
await expect(handler.handle('test')).rejects.toThrow('All handlers failed.');
|
||||
});
|
||||
|
||||
it('only calls the canHandle function once of its handlers when handleSafe is called.', async (): Promise<void> => {
|
||||
it('only calls the canHandle function once of its handlers when handleSafe is called.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([ handlerFalse, handlerTrue ]);
|
||||
|
||||
await expect(handler.handleSafe('test')).resolves.toEqual('test');
|
||||
@@ -67,7 +67,7 @@ describe('A CompositeAsyncHandler', (): void => {
|
||||
expect(handleFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('throws the same error as canHandle when calling handleSafe if no handler supports the data.', async (): Promise<void> => {
|
||||
it('throws the same error as canHandle when calling handleSafe if no handler supports the data.', async(): Promise<void> => {
|
||||
const handler = new CompositeAsyncHandler([ handlerFalse, handlerFalse ]);
|
||||
|
||||
await expect(handler.handleSafe(null)).rejects.toThrow('[Not supported., Not supported.]');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
describe('An UnsupportedHttpError', (): void => {
|
||||
it('has status code 400.', async (): Promise<void> => {
|
||||
it('has status code 400.', async(): Promise<void> => {
|
||||
const error = new UnsupportedHttpError('test');
|
||||
|
||||
expect(error.statusCode).toEqual(400);
|
||||
@@ -9,7 +9,7 @@ describe('An UnsupportedHttpError', (): void => {
|
||||
expect(error.name).toEqual('UnsupportedHttpError');
|
||||
});
|
||||
|
||||
it('has a default message if none was provided.', async (): Promise<void> => {
|
||||
it('has a default message if none was provided.', async(): Promise<void> => {
|
||||
const error = new UnsupportedHttpError();
|
||||
|
||||
expect(error.message).toEqual('The given input is not supported by the server configuration.');
|
||||
|
||||
Reference in New Issue
Block a user