A calm place to write long-form, and publish it to the open social web.
skypress.blog/
1import { describe, expect, it } from 'vitest';
2import { formatLongDate } from './dates';
3
4describe( 'formatLongDate', () => {
5 it( 'formats an ISO datetime as a long English date', () => {
6 expect( formatLongDate( '2026-06-09T12:00:00Z' ) ).toBe( 'June 9, 2026' );
7 } );
8
9 it( 'pins the calendar day to UTC regardless of time-of-day', () => {
10 // Late-evening UTC must not roll forward to the 10th.
11 expect( formatLongDate( '2026-06-09T23:30:00Z' ) ).toBe( 'June 9, 2026' );
12 // Early-morning UTC must not roll back to the 8th.
13 expect( formatLongDate( '2026-06-09T00:30:00Z' ) ).toBe( 'June 9, 2026' );
14 } );
15
16 it( 'accepts a date-only string', () => {
17 expect( formatLongDate( '2026-12-25' ) ).toBe( 'December 25, 2026' );
18 } );
19
20 it( 'falls back to the raw string for an unparseable date instead of throwing', () => {
21 // PDS records are untrusted; a malformed value must not crash rendering.
22 expect( formatLongDate( 'soon' ) ).toBe( 'soon' );
23 } );
24} );