mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Prevent server from crashing if requested data can't be handled
This commit is contained in:
@@ -20,6 +20,12 @@ describe('A SimpleResponseWriter', (): void => {
|
||||
await expect(writer.canHandle({ response })).rejects.toThrow(UnsupportedHttpError);
|
||||
});
|
||||
|
||||
it('requires the description body to be a string or binary stream if present.', async(): Promise<void> => {
|
||||
await expect(writer.canHandle({ response, description: { body: { dataType: 'quad' }} as ResponseDescription })).rejects.toThrow(UnsupportedHttpError);
|
||||
await expect(writer.canHandle({ response, description: { body: { dataType: 'string' }} as ResponseDescription })).resolves.toBeUndefined();
|
||||
await expect(writer.canHandle({ response, description: { body: { dataType: 'binary' }} as ResponseDescription })).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('responds with status code 200 and a location header if there is a description.', async(): Promise<void> => {
|
||||
await writer.handle({ response, description: { identifier: { path: 'path' }}});
|
||||
expect(response._isEndCalled()).toBeTruthy();
|
||||
|
||||
Reference in New Issue
Block a user