mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: More precise error messages
This commit is contained in:
@@ -12,14 +12,14 @@ describe('A SparqlPatchPermissionsExtractor', (): void => {
|
||||
const operation = { method: 'PATCH', body: { algebra: factory.createDeleteInsert() }} as unknown as Operation;
|
||||
await expect(extractor.canHandle(operation)).resolves.toBeUndefined();
|
||||
await expect(extractor.canHandle({ ...operation, method: 'GET' }))
|
||||
.rejects.toThrow(new UnsupportedHttpError('Only PATCH operations are supported.'));
|
||||
.rejects.toThrow(new UnsupportedHttpError('Cannot determine permissions of GET, only PATCH.'));
|
||||
await expect(extractor.canHandle({ ...operation, body: undefined }))
|
||||
.rejects.toThrow(new UnsupportedHttpError('PATCH body is required to determine permissions.'));
|
||||
.rejects.toThrow(new UnsupportedHttpError('Cannot determine permissions of PATCH operations without a body.'));
|
||||
await expect(extractor.canHandle({ ...operation, body: {} as SparqlUpdatePatch }))
|
||||
.rejects.toThrow(new UnsupportedHttpError('Only SPARQL update PATCHes are supported.'));
|
||||
.rejects.toThrow(new UnsupportedHttpError('Cannot determine permissions of non-SPARQL patches.'));
|
||||
await expect(extractor.canHandle({ ...operation,
|
||||
body: { algebra: factory.createMove('DEFAULT', 'DEFAULT') } as unknown as SparqlUpdatePatch }))
|
||||
.rejects.toThrow(new UnsupportedHttpError('Only DELETE/INSERT SPARQL update operations are supported.'));
|
||||
.rejects.toThrow(new UnsupportedHttpError('Cannot determine permissions of a PATCH without DELETE/INSERT.'));
|
||||
});
|
||||
|
||||
it('requires append for INSERT operations.', async(): Promise<void> => {
|
||||
|
||||
Reference in New Issue
Block a user