@@ -4,7 +4,7 @@ import { IsoDate, parse } from "./parse.js";
44import { parse as temporalParse } from "./test/temporal.js" ;
55
66// This test suite compares with Luxon output for maximum backwards compatibility
7- import { shouldSkip , VALID_TEST_CASES , INVALID_TEST_CASES , SUPPLIED_TEST_CASES } from './test/utils.js' ;
7+ import { shouldSkip , VALID_TEST_CASES , VALID_BUT_INVALID_IN_LUXON_TEST_CASES , INVALID_TEST_CASES , SUPPLIED_TEST_CASES } from './test/utils.js' ;
88
99// Some test cases from https://moment.github.io/luxon/#/parsing?id=ad-hoc-parsing
1010// ISO8601 date parsing https://github.com/11ty/eleventy/issues/3587
@@ -17,10 +17,26 @@ for(let line of VALID_TEST_CASES.split("\n")) {
1717 // assert.equal(received, expected)
1818
1919 // Compare to luxon
20- assert . equal ( parse ( line ) . toUTCString ( ) , DateTime . fromISO ( line , { zone : "utc" } ) . toJSDate ( ) . toUTCString ( ) ) ;
20+ assert . equal ( parse ( line ) . toUTCString ( ) , DateTime . fromISO ( line , { zone : "utc" } ) . toJSDate ( ) . toUTCString ( ) , `Invalid compared to luxon for ' ${ line } '` ) ;
2121
2222 // Compare to Temporal
23- assert . equal ( parse ( line ) . toUTCString ( ) , temporalParse ( line ) . toString ( ) ) ;
23+ assert . equal ( parse ( line ) . toUTCString ( ) , temporalParse ( line ) . toString ( ) , `Invalid compared to Temporal for '${ line } '` ) ;
24+ } ) ;
25+ }
26+
27+ for ( let line of VALID_BUT_INVALID_IN_LUXON_TEST_CASES . split ( "\n" ) ) {
28+ if ( shouldSkip ( line ) ) {
29+ continue ;
30+ }
31+
32+ test ( `Parse ${ line } ` , ( ) => {
33+ // assert.equal(received, expected)
34+
35+ // Should not equal luxon
36+ assert . notEqual ( parse ( line ) . toUTCString ( ) , DateTime . fromISO ( line , { zone : "utc" } ) . toJSDate ( ) . toUTCString ( ) , `Should not match luxon for '${ line } '` ) ;
37+
38+ // Compare to Temporal
39+ assert . equal ( parse ( line ) . toUTCString ( ) , temporalParse ( line ) . toString ( ) , `Invalid compared to Temporal for '${ line } '` ) ;
2440 } ) ;
2541}
2642
0 commit comments