From c29897ae653c182b82dd6237a3024db324ad4f27 Mon Sep 17 00:00:00 2001 From: iMaverick007 Date: Thu, 26 Mar 2026 13:55:09 +0530 Subject: [PATCH] Test: handle invalid _where JSON by falling back to query params --- src/app.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/app.test.ts b/src/app.test.ts index bac286d98..83c6cfa51 100644 --- a/src/app.test.ts +++ b/src/app.test.ts @@ -147,6 +147,22 @@ await test('createApp', async (t) => { assert.deepEqual(data, [{ id: '1', title: 'foo' }]) }) + await t.test('invalid _where falls back to query params', async () => { + const response = await fetch(`http://localhost:${port}/posts?title=foo&_where={invalid}` + ) + assert.equal(response.status, 200) + const data = await response.json() + assert.deepEqual(data, [{ id: '1', title: 'foo' }]) + }) + + await t.test('invalid _where returns all data when no query params', async () => { + const response = await fetch(`http://localhost:${port}/posts?_where={invalid}` + ) + assert.equal(response.status, 200) + const data = await response.json() + assert.deepEqual(data, [{ id: '1', title: 'foo' }]) + }) + await t.test('POST /posts with array body returns 400', async () => { const response = await fetch(`http://localhost:${port}/posts`, { method: 'POST',