We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e9da96e commit 0046632Copy full SHA for 0046632
1 file changed
app/api/track-user/route.test.ts
@@ -48,6 +48,17 @@ describe('POST /api/track-user', () => {
48
expect(data.success).toBe(false);
49
expect(data.error).toBe('Malformed JSON request body');
50
});
51
+ it('returns 400 when body is plain text (not JSON)', async () => {
52
+ const req = new Request('http://localhost/api/track-user', {
53
+ method: 'POST',
54
+ headers: { 'Content-Type': 'text/plain' },
55
+ body: 'not json',
56
+ });
57
+ const response = await POST(req);
58
+ expect(response.status).toBe(400);
59
+ const data = await response.json();
60
+ expect(data.success).toBe(false);
61
62
63
it('returns 400 when username is missing', async () => {
64
const response = await POST(makeRequest({}));
0 commit comments