formatSql.test.ts 646 B

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