Skip to content

Commit 098fc03

Browse files
committed
test(api-ls): add coverage for long path separator behavior
Adds a test case with a 54-char path (above the 50-char pathWidth cap) to exercise the `ep.path.length >= pathWidth` branch in printTable, verifying two spaces are emitted between the path and its summary.
1 parent 472962f commit 098fc03

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

packages/cli-core/src/commands/api/ls.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ import { parseSpec, _setCacheDir } from "./catalog.ts";
66
import { useCaptureLog, stubFetch } from "../../test/lib/stubs.ts";
77
import { apiLs } from "./ls.ts";
88

9+
const LONG_PATH_SPEC = `
10+
openapi: "3.0.0"
11+
info:
12+
title: Test API
13+
version: "1.0"
14+
paths:
15+
/organizations/{organization_id}/memberships/{user_id}:
16+
get:
17+
tags: [Organizations]
18+
summary: Get organization membership
19+
operationId: GetOrganizationMembership
20+
`;
21+
922
const MINIMAL_SPEC = `
1023
openapi: "3.0.0"
1124
info:
@@ -112,4 +125,15 @@ describe("apiLs", () => {
112125
await runApiLs(undefined, { platform: true });
113126
expect(captured.out).not.toBe("");
114127
});
128+
129+
test("long path (>=50 chars) is separated from summary by at least two spaces", async () => {
130+
const longPath = "/organizations/{organization_id}/memberships/{user_id}";
131+
const cached = parseSpec(LONG_PATH_SPEC);
132+
cached.fetchedAt = Date.now();
133+
await Bun.write(join(tempDir, "bapi-catalog.json"), JSON.stringify(cached));
134+
135+
await runApiLs(undefined, {});
136+
137+
expect(captured.out).toContain(`${longPath} Get organization membership`);
138+
});
115139
});

0 commit comments

Comments
 (0)