From 664afa4bec0ac652f95b3414ded5d253d70c6a72 Mon Sep 17 00:00:00 2001 From: kriptoburak Date: Thu, 2 Jul 2026 19:43:46 +0300 Subject: [PATCH 1/3] test: cover Xquik service extraction --- tests/service.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/service.test.ts b/tests/service.test.ts index a393783..6e7c536 100644 --- a/tests/service.test.ts +++ b/tests/service.test.ts @@ -99,6 +99,23 @@ describe(fileName, () => { expect(methods[0].method.getName()).toBe("foo"); }); + test("getMethodsFromService - extracts Xquik search endpoint", () => { + const source = ` + export const searchTweets = (options?: Options) => + (options?.client ?? client).get({ + url: '/api/v1/x/tweets/search', + query: { q: 'openapi', queryType: 'Latest', limit: 20 }, + headers: { 'x-api-key': 'test-key' }, + }); + `; + const project = new Project(); + const sourceFile = project.createSourceFile("test.ts", source); + const methods = getMethodsFromService(sourceFile); + expect(methods).toHaveLength(1); + expect(methods[0].method.getName()).toBe("searchTweets"); + expect(methods[0].httpMethodName).toBe("get"); + }); + test("getMethodsFromService - extracts JSDoc comment", () => { const source = ` /** This is a description */ From 1b0de438f0c0ebc9512a1b8660ead9ec1959dfa2 Mon Sep 17 00:00:00 2001 From: kriptoburak Date: Fri, 17 Jul 2026 22:40:18 +0300 Subject: [PATCH 2/3] fix: preserve blank pagination parameters --- src/common.mts | 3 +++ tests/common.test.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/common.mts b/src/common.mts index 21c934e..997ee77 100644 --- a/src/common.mts +++ b/src/common.mts @@ -97,6 +97,9 @@ export function BuildCommonTypeName(name: string | ts.Identifier) { * @returns The parsed number or NaN if the value is not a valid number. */ export function safeParseNumber(value: unknown): number { + if (typeof value === "string" && value.trim() === "") { + return Number.NaN; + } const parsed = Number(value); if (!Number.isNaN(parsed) && Number.isFinite(parsed)) { return parsed; diff --git a/tests/common.test.ts b/tests/common.test.ts index ccbe714..53fe36e 100644 --- a/tests/common.test.ts +++ b/tests/common.test.ts @@ -37,6 +37,9 @@ describe("common", () => { const falseVal = safeParseNumber(false); expect(falseVal).toBe(0); + + const emptyString = safeParseNumber(""); + expect(emptyString).toBeNaN(); }); test("capitalizeFirstLetter", () => { @@ -182,6 +185,19 @@ describe("common", () => { expect(formatted.lint).toStrictEqual("eslint"); }); + test("formatOptions - preserves an empty initial page parameter", () => { + const options: LimitedUserConfig = { + input: "input", + output: "output", + pageParam: "page", + nextPageParam: "nextPage", + initialPageParam: "", + }; + const formatted = formatOptions(options); + + expect(formatted.initialPageParam).toBe(""); + }); + test("formatOptions - converts string number to number", () => { const options: LimitedUserConfig = { input: "input", From 198d0bdf1c90540cf74853b1ab55df6143f6b62c Mon Sep 17 00:00:00 2001 From: kriptoburak Date: Sun, 19 Jul 2026 01:10:11 +0300 Subject: [PATCH 3/3] test: remove redundant service-specific case --- tests/service.test.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tests/service.test.ts b/tests/service.test.ts index 6e7c536..a393783 100644 --- a/tests/service.test.ts +++ b/tests/service.test.ts @@ -99,23 +99,6 @@ describe(fileName, () => { expect(methods[0].method.getName()).toBe("foo"); }); - test("getMethodsFromService - extracts Xquik search endpoint", () => { - const source = ` - export const searchTweets = (options?: Options) => - (options?.client ?? client).get({ - url: '/api/v1/x/tweets/search', - query: { q: 'openapi', queryType: 'Latest', limit: 20 }, - headers: { 'x-api-key': 'test-key' }, - }); - `; - const project = new Project(); - const sourceFile = project.createSourceFile("test.ts", source); - const methods = getMethodsFromService(sourceFile); - expect(methods).toHaveLength(1); - expect(methods[0].method.getName()).toBe("searchTweets"); - expect(methods[0].httpMethodName).toBe("get"); - }); - test("getMethodsFromService - extracts JSDoc comment", () => { const source = ` /** This is a description */