Results.utils.test.ts48 lines · main
| 1 | import { describe, expect, test } from 'vitest' |
| 2 | |
| 3 | import { |
| 4 | formatCellValue, |
| 5 | formatClipboardValue, |
| 6 | } from '@/components/interfaces/SQLEditor/UtilityPanel/Results.utils' |
| 7 | |
| 8 | describe('formatClipboardValue', () => { |
| 9 | test('returns empty string for null', () => { |
| 10 | expect(formatClipboardValue(null)).toBe('') |
| 11 | }) |
| 12 | |
| 13 | test('stringifies objects', () => { |
| 14 | expect(formatClipboardValue({ a: 1 })).toBe('{"a":1}') |
| 15 | }) |
| 16 | |
| 17 | test('stringifies arrays', () => { |
| 18 | expect(formatClipboardValue([1, 2])).toBe('[1,2]') |
| 19 | }) |
| 20 | |
| 21 | test('converts primitives to string', () => { |
| 22 | expect(formatClipboardValue('hello')).toBe('hello') |
| 23 | expect(formatClipboardValue(42)).toBe('42') |
| 24 | expect(formatClipboardValue(false)).toBe('false') |
| 25 | }) |
| 26 | }) |
| 27 | |
| 28 | describe('formatCellValue', () => { |
| 29 | test('returns NULL for null', () => { |
| 30 | expect(formatCellValue(null)).toBe('NULL') |
| 31 | }) |
| 32 | |
| 33 | test('returns strings as-is', () => { |
| 34 | expect(formatCellValue('hello')).toBe('hello') |
| 35 | }) |
| 36 | |
| 37 | test('stringifies objects', () => { |
| 38 | expect(formatCellValue({ a: 1 })).toBe('{"a":1}') |
| 39 | }) |
| 40 | |
| 41 | test('stringifies numbers', () => { |
| 42 | expect(formatCellValue(42)).toBe('42') |
| 43 | }) |
| 44 | |
| 45 | test('stringifies booleans', () => { |
| 46 | expect(formatCellValue(true)).toBe('true') |
| 47 | }) |
| 48 | }) |