From a288a29cc0955f564e0410688e70bcd46138104c Mon Sep 17 00:00:00 2001 From: saltyaom Date: Fri, 5 Apr 2024 22:24:52 +0700 Subject: [PATCH] :wrench: fix: null schema --- package.json | 2 +- test/validator/response.test.ts | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 61c0bc59..7e4d82cc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "elysia", "description": "Ergonomic Framework for Human", - "version": "1.0.11", + "version": "1.0.12", "author": { "name": "saltyAom", "url": "https://github.com/SaltyAom", diff --git a/test/validator/response.test.ts b/test/validator/response.test.ts index 51dbccc9..86451618 100644 --- a/test/validator/response.test.ts +++ b/test/validator/response.test.ts @@ -333,4 +333,43 @@ describe('Response Validator', () => { ]) }) }) + + it('return void with schema', async () => { + const app = new Elysia().get('/', () => undefined, { + response: t.Union([ + t.Void(), + t.Object({ + name: t.String() + }) + ]) + }) + }) + + it('return null with status based schema', async () => { + const app = new Elysia().get('/', () => undefined, { + response: { + 200: t.Union([ + t.Void(), + t.Object({ + name: t.String() + }) + ]), + 418: t.String() + } + }) + }) + + it('return static undefined with status based schema', async () => { + const app = new Elysia().get('/', undefined, { + response: { + 200: t.Union([ + t.Void(), + t.Object({ + name: t.String() + }) + ]), + 418: t.String() + } + }) + }) })