Skip to content

Commit 53da9e4

Browse files
committed
test: add SQL token type tests for parenthesis and identifier coverage
Add 3 tests that exercise specific token types in colorizeSql: - Parentheses (LeftParenthesis/RightParenthesis) → muted coloring (lines 66-69) - Nested function call tokens → exercises nested token handling - Identifier tokens → exercises default switch case (line 70-71)
1 parent f044a85 commit 53da9e4

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

test/lib/formatters/sql.property.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,32 @@ describe("property: colorizeSql", () => {
182182
);
183183
});
184184
});
185+
186+
// ---------------------------------------------------------------------------
187+
// Additional colorizeSql cases to cover specific token types
188+
// ---------------------------------------------------------------------------
189+
190+
describe("colorizeSql — parenthesis and default token types", () => {
191+
test("handles SQL with parentheses (LeftParenthesis/RightParenthesis tokens)", () => {
192+
const sql = "SELECT COUNT(*) FROM users WHERE id IN (1, 2, 3)";
193+
const result = colorizeSql(sql);
194+
// Parentheses should be muted but still present
195+
expect(stripAnsi(result)).toContain("(");
196+
expect(stripAnsi(result)).toContain(")");
197+
});
198+
199+
test("handles SQL with function call returning nested tokens", () => {
200+
const sql = "SELECT MAX(age), MIN(salary) FROM employees";
201+
const result = colorizeSql(sql);
202+
expect(stripAnsi(result)).toContain("MAX");
203+
expect(stripAnsi(result)).toContain("MIN");
204+
});
205+
206+
test("handles SQL with default token (identifier)", () => {
207+
const sql = "SELECT user_name, email FROM user_profile";
208+
const result = colorizeSql(sql);
209+
// Identifiers use default coloring (no specific case in switch)
210+
expect(stripAnsi(result)).toContain("user_name");
211+
expect(stripAnsi(result)).toContain("email");
212+
});
213+
});

0 commit comments

Comments
 (0)