formatSql.test.ts24 lines · main
1import { describe, expect, it } from 'vitest'
2
3import { formatSql } from './formatSql'
4
5describe('formatSql', () => {
6 it('should format SQL', () => {
7 const result = formatSql('SELECT * FROM users')
8
9 expect(result).toBe(`select
10 *
11from
12 users`)
13 })
14
15 it('should return the original argument if it is not valid, not throw', () => {
16 const result = formatSql('123')
17 expect(result).toBe('123')
18 })
19
20 it('should return the original argument if it is not valid, not throw', () => {
21 const result = formatSql('select {col1}, {col2} from {tableName};')
22 expect(result).toBe('select {col1}, {col2} from {tableName};')
23 })
24})