feat: enhance test coverage with additional formatting cases#4
feat: enhance test coverage with additional formatting cases#4JoelMiller74 merged 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances test coverage for the T-SQL formatter engine by adding 17 new test cases covering various formatting configurations. The tests verify formatter behavior for options like dense operators, parenthesis spacing, join alignment, logical operator positioning, alias keywords, CTE styles, window functions, column definition alignment, and bracket identifier handling.
Key Changes
- Added comprehensive test coverage for configuration options previously untested in the Vitest suite
- Tests validate edge cases and specific formatting behaviors for different config combinations
| it('tabulate alias', () => { | ||
| const t = 'SELECT a AS alias, verylongcolumn AS longer FROM t'; | ||
| const out = formatTsql(t, { options: {} as any, config: cfg({ newlineAfterSelect: true, tabulateAlias: true }), profile: {} }); | ||
| expect(out).toBe('SELECT\n a AS alias, verylongcolumn AS longer\nFROM t'); |
There was a problem hiding this comment.
The expected output appears to be incorrect. With newlineAfterSelect: true, the formatter puts each column on a separate line (joined with newlines on line 142 of engine.ts). The expected output should have each column on its own line, something like:
expect(/SELECT\n\s+a.*AS alias,?\n\s+verylongcolumn.*AS longer\nFROM/.test(out)).toBe(true);Additionally, with tabulateAlias: true, the code adds padding to align the AS keywords, which is not reflected in the current expected value.
| expect(out).toBe('SELECT\n a AS alias, verylongcolumn AS longer\nFROM t'); | |
| expect(/SELECT\n\s+a\s+AS alias,?\n\s+verylongcolumn\s+AS longer\nFROM t/.test(out)).toBe(true); |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.