Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
vardanbansal-harness committed Feb 27, 2025
1 parent 3bcc9eb commit e3b24e6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/ui/src/utils/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest'

import { formatDate } from '../utils'

describe('formatDate', () => {
it('should format a Unix timestamp to a localized date string', () => {
const timestamp = 1642774800000
const result = formatDate(timestamp)
expect(result).toBe('Jan 21, 2022')
})

it('should format an ISO date string to a localized date string with full style', () => {
const timestamp = '2022-01-21'
const result = formatDate(timestamp, 'full')
expect(result).toBe('Friday, January 21, 2022')
})

it('should return an empty string if timestamp is falsy', () => {
const result = formatDate('')
expect(result).toBe('')
})

it('should handle invalid date gracefully and return an empty string', () => {
const result = formatDate('invalid-date')
expect(result).toBe('')
})
})

0 comments on commit e3b24e6

Please sign in to comment.