Skip to content

Commit

Permalink
fix: Remove duplicate checks
Browse files Browse the repository at this point in the history
These were added when setting TypeScript settings to strict,
but should not be needed due to how AsyncHandlers should be used.
  • Loading branch information
joachimvh committed Aug 25, 2020
1 parent bca4d06 commit 4bc1dcd
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 16 deletions.
5 changes: 1 addition & 4 deletions src/ldp/http/SimpleRequestParser.ts
Expand Up @@ -42,9 +42,6 @@ export class SimpleRequestParser extends RequestParser {
const preferences = await this.preferenceParser.handleSafe(input);
const body = await this.bodyParser.handleSafe(input);

if (!input.method) {
throw new Error('Missing method.');
}
return { method: input.method, target, preferences, body };
return { method: input.method!, target, preferences, body };
}
}
5 changes: 1 addition & 4 deletions src/ldp/operations/SimplePostOperationHandler.ts
Expand Up @@ -26,10 +26,7 @@ export class SimplePostOperationHandler extends OperationHandler {
}

public async handle(input: Operation): Promise<ResponseDescription> {
if (!input.body) {
throw new UnsupportedHttpError('POST operations require a body.');
}
const identifier = await this.store.addResource(input.target, input.body);
const identifier = await this.store.addResource(input.target, input.body!);
return { identifier };
}
}
4 changes: 0 additions & 4 deletions test/unit/ldp/http/SimpleRequestParser.test.ts
Expand Up @@ -29,10 +29,6 @@ describe('A SimpleRequestParser', (): void => {
await expect(requestParser.canHandle({ url: 'url' } as any)).rejects.toThrow('Missing method.');
});

it('errors if called without method.', async(): Promise<void> => {
await expect(requestParser.handle({ url: 'url' } as any)).rejects.toThrow('Missing method.');
});

it('returns the output of all input parsers after calling handle.', async(): Promise<void> => {
await expect(requestParser.handle({ url: 'url', method: 'GET' } as any)).resolves.toEqual({
method: 'GET',
Expand Down
4 changes: 0 additions & 4 deletions test/unit/ldp/operations/SimplePostOperationHandler.test.ts
Expand Up @@ -18,10 +18,6 @@ describe('A SimplePostOperationHandler', (): void => {
await expect(handler.canHandle({ method: 'POST' } as Operation)).rejects.toThrow(UnsupportedHttpError);
});

it('errors if no body is present.', async(): Promise<void> => {
await expect(handler.handle({ method: 'POST' } as Operation)).rejects.toThrow(UnsupportedHttpError);
});

it('adds the given representation to the store and returns the new identifier.', async(): Promise<void> => {
await expect(handler.handle({ method: 'POST', body: { dataType: 'test' }} as Operation))
.resolves.toEqual({ identifier: { path: 'newPath' }});
Expand Down

0 comments on commit 4bc1dcd

Please sign in to comment.