mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
27 lines
903 B
TypeScript
27 lines
903 B
TypeScript
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);
|
|
});
|
|
});
|