CommunitySolidServer/test/unit/identity/interaction/FixedInteractionHandler.test.ts
2022-02-11 10:52:45 +01:00

16 lines
742 B
TypeScript

import type { Operation } from '../../../../src/http/Operation';
import { FixedInteractionHandler } from '../../../../src/identity/interaction/FixedInteractionHandler';
import { readJsonStream } from '../../../../src/util/StreamUtil';
describe('A FixedInteractionHandler', (): void => {
const json = { data: 'data' };
const operation: Operation = { target: { path: 'http://example.com/test/' }} as any;
const handler = new FixedInteractionHandler(json);
it('returns the given JSON as response.', async(): Promise<void> => {
const response = await handler.handle({ operation });
await expect(readJsonStream(response.data)).resolves.toEqual(json);
expect(response.metadata.contentType).toBe('application/json');
});
});