From 31f9ba84fcc2cdf35a3987a0fdc3e78b157c375c Mon Sep 17 00:00:00 2001 From: solufa Date: Thu, 14 Nov 2024 21:58:54 +0900 Subject: [PATCH] fix: update parseStringArrayTypeQueryParams test --- servers/all/$server.ts | 4 +--- src/buildServerFile.ts | 4 +--- tests/index.spec.ts | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/servers/all/$server.ts b/servers/all/$server.ts index fb4d3a2..b08b15b 100644 --- a/servers/all/$server.ts +++ b/servers/all/$server.ts @@ -113,9 +113,7 @@ const parseStringArrayTypeQueryParams = (stringArrayTypeParams: [string, boolean if (!isOptional && param === undefined) { query[key] = []; } else if (!isOptional || param !== undefined) { - const vals = (Array.isArray(param) ? param : [param]); - - query[key] = vals; + query[key] = Array.isArray(param) ? param : [param]; } delete query[`${key}[]`]; diff --git a/src/buildServerFile.ts b/src/buildServerFile.ts index f64f3e5..c05d30f 100644 --- a/src/buildServerFile.ts +++ b/src/buildServerFile.ts @@ -144,9 +144,7 @@ const parseStringArrayTypeQueryParams = (stringArrayTypeParams: [string, boolean if (!isOptional && param === undefined) { query[key] = []; } else if (!isOptional || param !== undefined) { - const vals = (Array.isArray(param) ? param : [param]); - - query[key] = vals; + query[key] = Array.isArray(param) ? param : [param]; } delete query[\`\${key}[]\`]; diff --git a/tests/index.spec.ts b/tests/index.spec.ts index 2f9a91f..9d21609 100644 --- a/tests/index.spec.ts +++ b/tests/index.spec.ts @@ -215,12 +215,12 @@ test('PUT: zod validations', async () => { fetchClient.put({ query: { requiredNum: 0, - requiredNumArr: [], + requiredNumArr: [1], id: '1', strArray: [], disable: 'true', bool: 1 as any, - boolArray: [], + boolArray: [true], }, body: { port }, }),