29 行
849 B
TypeScript
29 行
849 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { cn, originalCreatedAtString, toDate } from '@/lib/utils'
|
|
|
|
describe ('utils', () => {
|
|
it ('converts strings to dates and leaves date instances intact', () => {
|
|
const date = new Date ('2026-01-02T03:04:05Z')
|
|
|
|
expect (toDate ('2026-01-02T03:04:05Z')).toBeInstanceOf (Date)
|
|
expect (toDate (date)).toBe (date)
|
|
})
|
|
|
|
it ('merges conditional Tailwind classes', () => {
|
|
const hidden = false
|
|
|
|
expect (cn ('p-2', hidden && 'hidden', 'p-4')).toBe ('p-4')
|
|
})
|
|
|
|
it ('renders unknown original creation time ranges', () => {
|
|
expect (originalCreatedAtString (null, null)).toBe ('年月日不詳')
|
|
expect (
|
|
originalCreatedAtString (
|
|
'2026-01-01T00:00:00+09:00',
|
|
'2026-01-02T00:00:00+09:00',
|
|
),
|
|
).toContain ('時刻不詳')
|
|
})
|
|
})
|