Skip to content

Commit a3958d6

Browse files
committed
add tests
1 parent aeda450 commit a3958d6

File tree

5 files changed

+4725
-773
lines changed

5 files changed

+4725
-773
lines changed

MyApp.Client/lib/utils.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { describe, it, expect } from 'vitest'
2+
import { formatCurrency, formatDate, dateInputFormat } from './utils'
3+
4+
describe('utils', () => {
5+
describe('formatCurrency', () => {
6+
it('should format number as USD currency', () => {
7+
expect(formatCurrency(100)).toBe('$100.00')
8+
expect(formatCurrency(1234.56)).toBe('$1,234.56')
9+
})
10+
11+
it('should return empty string for falsy values', () => {
12+
expect(formatCurrency(undefined)).toBe('')
13+
expect(formatCurrency(0)).toBe('')
14+
})
15+
})
16+
17+
describe('dateInputFormat', () => {
18+
it('should format date with dashes', () => {
19+
const date = new Date('2025-11-11T00:00:00Z')
20+
const result = dateInputFormat(date)
21+
// Result will be in format like "11-11-2025" or "2025-11-11" depending on locale
22+
expect(result).toMatch(/\d{1,4}-\d{1,2}-\d{1,4}/)
23+
})
24+
})
25+
})
26+

0 commit comments

Comments
 (0)