@@ -28,11 +28,8 @@ const createFixture = async content => {
2828 return root ;
2929} ;
3030
31- const runFixture = ( root , timeZone = 'UTC' ) =>
32- execFileAsync ( process . execPath , [ 'scripts/data/blog.mjs' ] , {
33- cwd : root ,
34- env : { ...process . env , TZ : timeZone } ,
35- } ) ;
31+ const runFixture = root =>
32+ execFileAsync ( process . execPath , [ 'scripts/data/blog.mjs' ] , { cwd : root } ) ;
3633
3734test ( 'generates blog data for valid dates' , async t => {
3835 const root = await createFixture ( "---\ndate: '2026-09-22'\n---\n# Test\n" ) ;
@@ -46,105 +43,25 @@ test('generates blog data for valid dates', async t => {
4643 assert . equal ( posts [ 0 ] . date , '2026-09-22T00:00:00.000Z' ) ;
4744} ) ;
4845
49- test ( 'normalizes offset-less quoted date-times as UTC' , async t => {
50- const root = await createFixture (
51- "---\ndate: '2026-09-22 10:00'\n---\n# Test\n"
52- ) ;
53- t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
54-
55- const dates = [ ] ;
56- for ( const timeZone of [ 'UTC' , 'America/Los_Angeles' ] ) {
57- await runFixture ( root , timeZone ) ;
58- const posts = JSON . parse (
59- await readFile ( join ( root , 'generated' , 'blog.json' ) , 'utf8' )
60- ) ;
61- dates . push ( posts [ 0 ] . date ) ;
62- }
63-
64- assert . deepEqual ( dates , [
65- '2026-09-22T10:00:00.000Z' ,
66- '2026-09-22T10:00:00.000Z' ,
67- ] ) ;
68- } ) ;
69-
7046test ( 'reports the file for an invalid blog date' , async t => {
7147 const root = await createFixture ( '---\ndate: not-a-date\n---\n# Test\n' ) ;
7248 t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
7349
7450 await assert . rejects ( runFixture ( root ) , error => {
75- assert . match ( error . stderr , / I n v a l i d B l o g D a t e E r r o r : I n v a l i d b l o g d a t e / ) ;
51+ assert . match ( error . stderr , / I n v a l i d o r m i s s i n g b l o g d a t e / ) ;
7652 assert . match ( error . stderr , / p a g e s [ \\ / ] b l o g [ \\ / ] p o s t s [ \\ / ] e x a m p l e \. m d / ) ;
7753 assert . match ( error . stderr , / n o t - a - d a t e / ) ;
7854 return true ;
7955 } ) ;
8056} ) ;
8157
82- test ( 'rejects nonexistent calendar dates' , async t => {
83- const root = await createFixture ( '---\ndate: 2026-02-30\n---\n# Test\n' ) ;
84- t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
85-
86- await assert . rejects ( runFixture ( root ) , error => {
87- assert . match ( error . stderr , / I n v a l i d b l o g d a t e / ) ;
88- assert . match ( error . stderr , / 2 0 2 6 - 0 2 - 3 0 / ) ;
89- return true ;
90- } ) ;
91- } ) ;
92-
93- test ( 'rejects one-digit dates that roll over' , async t => {
94- const root = await createFixture (
95- '---\ndate: 2024-2-30 10:00:00\n---\n# Test\n'
96- ) ;
97- t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
98-
99- await assert . rejects ( runFixture ( root ) , error => {
100- assert . match ( error . stderr , / I n v a l i d b l o g d a t e / ) ;
101- assert . match ( error . stderr , / 2 0 2 4 - 2 - 3 0 / ) ;
102- return true ;
103- } ) ;
104- } ) ;
105-
106- test ( 'rejects out-of-range time components' , async t => {
107- const root = await createFixture (
108- '---\ndate: 2024-01-01 25:60:60\n---\n# Test\n'
109- ) ;
110- t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
111-
112- await assert . rejects ( runFixture ( root ) , error => {
113- assert . match ( error . stderr , / I n v a l i d b l o g d a t e / ) ;
114- assert . match ( error . stderr , / 2 5 : 6 0 : 6 0 / ) ;
115- return true ;
116- } ) ;
117- } ) ;
118-
119- test ( 'accepts ISO end-of-day timestamps' , async t => {
120- for ( const value of [ '2026-09-22T24:00:00Z' , '2026-09-22 24:00' ] ) {
121- const root = await createFixture ( `---\ndate: '${ value } '\n---\n# Test\n` ) ;
122- t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
123-
124- await runFixture ( root ) ;
125- }
126- } ) ;
127-
128- test ( 'rejects nonzero end-of-day time components' , async t => {
129- const root = await createFixture (
130- "---\ndate: '2026-09-22T24:00:01Z'\n---\n# Test\n"
131- ) ;
132- t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
133-
134- await assert . rejects ( runFixture ( root ) , error => {
135- assert . match ( error . stderr , / I n v a l i d b l o g d a t e / ) ;
136- assert . match ( error . stderr , / 2 4 : 0 0 : 0 1 / ) ;
137- return true ;
138- } ) ;
139- } ) ;
140-
14158test ( 'reports the file for a missing blog date' , async t => {
14259 const root = await createFixture ( '---\ntitle: Test\n---\n# Test\n' ) ;
14360 t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
14461
14562 await assert . rejects ( runFixture ( root ) , error => {
146- assert . match ( error . stderr , / I n v a l i d b l o g d a t e / ) ;
147- assert . match ( error . stderr , / e x a m p l e \. m d / ) ;
63+ assert . match ( error . stderr , / I n v a l i d o r m i s s i n g b l o g d a t e / ) ;
64+ assert . match ( error . stderr , / p a g e s [ \\ / ] b l o g [ \\ / ] p o s t s [ \\ / ] e x a m p l e \. m d / ) ;
14865 assert . match ( error . stderr , / < m i s s i n g > / ) ;
14966 return true ;
15067 } ) ;
0 commit comments