Tofu/tests/dates/formatDayLabel.test.js

26 lines
844 B
JavaScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { formatDayLabel } from '#tofu/tools/dates/formatDayLabel.js'
test('formats a Monday as an uppercase French weekday and its day number', () => {
assert.equal(formatDayLabel(new Date(2026, 8, 21)), 'LUNDI 21')
})
test('formats the last day of the week', () => {
assert.equal(formatDayLabel(new Date(2026, 8, 27)), 'DIMANCHE 27')
})
test('leaves a single digit day unpadded', () => {
assert.equal(formatDayLabel(new Date(2026, 0, 1)), 'JEUDI 1')
})
test('ignores the time of day', () => {
assert.equal(formatDayLabel(new Date(2026, 8, 23, 23, 59)), 'MERCREDI 23')
})
test('does not mutate the received date', () => {
const date = new Date(2026, 8, 21, 8, 0)
const before = date.getTime()
formatDayLabel(date)
assert.equal(date.getTime(), before)
})