Skip to content

Commit e26f35e

Browse files
committed
Increased the test coverage
1 parent 29eb70c commit e26f35e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/event-handler/tests/unit/http/middleware/validation.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,24 @@ describe('Validation Middleware', () => {
368368
name: 'John',
369369
});
370370
});
371+
372+
it('validates non-JSON request body (text/plain)', async () => {
373+
// Prepare
374+
const textSchema = z.string();
375+
app.post('/text', async () => ({ statusCode: 200, body: 'OK' }), {
376+
validation: { req: { body: textSchema } },
377+
});
378+
const event = {
379+
...createTestEvent('/text', 'POST', {
380+
'content-type': 'text/plain',
381+
}),
382+
body: 'plain text content',
383+
};
384+
385+
// Act
386+
const result = await app.resolve(event, context);
387+
388+
// Assess
389+
expect(result.statusCode).toBe(HttpStatusCodes.OK);
390+
});
371391
});

0 commit comments

Comments
 (0)