mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Use asynchandler library for handlers
This commit is contained in:
26
test/unit/util/handlers/StatusBooleanHandler.test.ts
Normal file
26
test/unit/util/handlers/StatusBooleanHandler.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { AsyncHandler } from 'asynchronous-handlers';
|
||||
import { StatusBooleanHandler } from '../../../../src/util/handlers/StatusBooleanHandler';
|
||||
|
||||
describe('A StatusBooleanHandler', (): void => {
|
||||
let handlers: jest.Mocked<AsyncHandler<string, boolean>>[];
|
||||
let handler: StatusBooleanHandler<string>;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
handlers = [
|
||||
{
|
||||
canHandle: jest.fn(),
|
||||
handle: jest.fn().mockResolvedValue(false),
|
||||
} satisfies Partial<AsyncHandler<string, boolean>> as any,
|
||||
{
|
||||
canHandle: jest.fn(),
|
||||
handle: jest.fn().mockResolvedValue(true),
|
||||
} satisfies Partial<AsyncHandler<string, boolean>> as any,
|
||||
];
|
||||
|
||||
handler = new StatusBooleanHandler(handlers);
|
||||
});
|
||||
|
||||
it('returns true if one of the handlers returns true.', async(): Promise<void> => {
|
||||
await expect(handler.handleSafe('input')).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user