mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
24 lines
1.2 KiB
TypeScript
24 lines
1.2 KiB
TypeScript
import { GetOperationHandler } from '../../../../src/ldp/operations/GetOperationHandler';
|
|
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
|
import type { Representation } from '../../../../src/ldp/representation/Representation';
|
|
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
|
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
|
|
|
describe('A GetOperationHandler', (): void => {
|
|
const store = {
|
|
getRepresentation: async(): Promise<Representation> => ({ binary: false } as Representation),
|
|
} as unknown as ResourceStore;
|
|
const handler = new GetOperationHandler(store);
|
|
|
|
it('only supports GET operations.', async(): Promise<void> => {
|
|
await expect(handler.canHandle({ method: 'GET' } as Operation)).resolves.toBeUndefined();
|
|
await expect(handler.canHandle({ method: 'POST' } as Operation)).rejects.toThrow(UnsupportedHttpError);
|
|
});
|
|
|
|
it('returns the representation from the store with the input identifier.', async(): Promise<void> => {
|
|
await expect(handler.handle({ target: { path: 'url' }} as Operation)).resolves.toEqual(
|
|
{ identifier: { path: 'url' }, body: { binary: false }},
|
|
);
|
|
});
|
|
});
|