@@ -186,6 +186,63 @@ describe('shared-serialization', () => {
186186 (6 chars)"
187187 ` ) ;
188188 } ) ;
189+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalDuration ) , async ( ) => {
190+ expect ( await dump ( Temporal . Duration . from ( 'PT194972H22M2.783S' ) ) ) . toMatchInlineSnapshot ( `
191+ "
192+ 0 TemporalDuration "PT194972H22M2.783S"
193+ (25 chars)"
194+ ` ) ;
195+ } ) ;
196+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalInstant ) , async ( ) => {
197+ expect ( await dump ( Temporal . Instant . from ( '2003-12-29T00:00:00Z' ) ) ) . toMatchInlineSnapshot ( `
198+ "
199+ 0 TemporalInstant "2003-12-29T00:00:00Z"
200+ (27 chars)"
201+ ` ) ;
202+ } ) ;
203+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalPlainDate ) , async ( ) => {
204+ expect ( await dump ( Temporal . PlainDate . from ( '2003-12-29' ) ) ) . toMatchInlineSnapshot ( `
205+ "
206+ 0 TemporalPlainDate "2003-12-29"
207+ (17 chars)"
208+ ` ) ;
209+ } ) ;
210+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalPlainDateTime ) , async ( ) => {
211+ expect ( await dump ( Temporal . PlainDateTime . from ( '2003-12-29T04:20:00' ) ) ) . toMatchInlineSnapshot ( `
212+ "
213+ 0 TemporalPlainDateTime "2003-12-29T04:20:00"
214+ (26 chars)"
215+ ` ) ;
216+ } ) ;
217+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalPlainMonthDay ) , async ( ) => {
218+ expect ( await dump ( Temporal . PlainMonthDay . from ( '12-29' ) ) ) . toMatchInlineSnapshot ( `
219+ "
220+ 0 TemporalPlainMonthDay "12-29"
221+ (12 chars)"
222+ ` ) ;
223+ } ) ;
224+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalPlainTime ) , async ( ) => {
225+ expect ( await dump ( Temporal . PlainTime . from ( '04:20:00' ) ) ) . toMatchInlineSnapshot ( `
226+ "
227+ 0 TemporalPlainTime "04:20:00"
228+ (15 chars)"
229+ ` ) ;
230+ } ) ;
231+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalPlainYearMonth ) , async ( ) => {
232+ expect ( await dump ( Temporal . PlainYearMonth . from ( '2003-12' ) ) ) . toMatchInlineSnapshot ( `
233+ "
234+ 0 TemporalPlainYearMonth "2003-12"
235+ (14 chars)"
236+ ` ) ;
237+ } ) ;
238+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( TypeIds . TemporalZonedDateTime ) , async ( ) => {
239+ expect ( await dump ( Temporal . ZonedDateTime . from ( '2003-12-29T04:20:00+01:00[Europe/Berlin]' ) ) )
240+ . toMatchInlineSnapshot ( `
241+ "
242+ 0 TemporalZonedDateTime "2003-12-29T04:20:00+01:00[Europe/Berlin]"
243+ (47 chars)"
244+ ` ) ;
245+ } ) ;
189246 it ( title ( TypeIds . Regex ) , async ( ) => {
190247 expect ( await dump ( / a b c / gm) ) . toMatchInlineSnapshot ( `
191248 "
@@ -995,6 +1052,32 @@ describe('shared-serialization', () => {
9951052 expect ( date ) . toBeInstanceOf ( Date ) ;
9961053 expect ( date . toISOString ( ) ) . toBe ( '2009-02-13T23:31:30.000Z' ) ;
9971054 } ) ;
1055+ const testTemporal = ( id : TypeIds , T_ : ( ) => typeof __TemporalStub < unknown > , value : string ) => {
1056+ it . skipIf ( typeof Temporal === 'undefined' ) ( title ( id ) , async ( ) => {
1057+ const T = T_ ( ) ;
1058+ const original = T . from ( value ) ;
1059+ const objs = await serialize ( original ) ;
1060+ const deserialized = deserialize ( objs ) [ 0 ] ;
1061+ expect ( deserialized ) . toBeInstanceOf ( T ) ;
1062+ expect ( original ) . toEqual ( deserialized ) ;
1063+ } ) ;
1064+ } ;
1065+ testTemporal ( TypeIds . TemporalDuration , ( ) => Temporal . Duration , 'PT194972H22M2.783S' ) ;
1066+ testTemporal ( TypeIds . TemporalInstant , ( ) => Temporal . Instant , '2003-12-29T00:00:00Z' ) ;
1067+ testTemporal ( TypeIds . TemporalPlainDate , ( ) => Temporal . PlainDate , '2003-12-29' ) ;
1068+ testTemporal (
1069+ TypeIds . TemporalPlainDateTime ,
1070+ ( ) => Temporal . PlainDateTime ,
1071+ '2003-12-29T04:20:00'
1072+ ) ;
1073+ testTemporal ( TypeIds . TemporalPlainMonthDay , ( ) => Temporal . PlainMonthDay , '12-29' ) ;
1074+ testTemporal ( TypeIds . TemporalPlainTime , ( ) => Temporal . PlainTime , '04:20:00' ) ;
1075+ testTemporal ( TypeIds . TemporalPlainYearMonth , ( ) => Temporal . PlainYearMonth , '2003-12' ) ;
1076+ testTemporal (
1077+ TypeIds . TemporalZonedDateTime ,
1078+ ( ) => Temporal . ZonedDateTime ,
1079+ '2003-12-29T04:20:00+01:00[Europe/Berlin]'
1080+ ) ;
9981081 it ( title ( TypeIds . Regex ) , async ( ) => {
9991082 const objs = await serialize ( / a b c / gm) ;
10001083 const regex = deserialize ( objs ) [ 0 ] as RegExp ;
0 commit comments