@@ -2627,6 +2627,99 @@ test('listItem', (t) => {
2627
2627
'should not use a different bullet for an empty list item at non-head in two lists'
2628
2628
)
2629
2629
2630
+ t . equal (
2631
+ to (
2632
+ {
2633
+ type : 'list' ,
2634
+ ordered : true ,
2635
+ children : [ { type : 'listItem' , children : [ ] } ]
2636
+ } ,
2637
+ { bulletOrdered : ')' }
2638
+ ) ,
2639
+ '1)\n' ,
2640
+ 'should support `bulletOrdered`'
2641
+ )
2642
+
2643
+ t . throws (
2644
+ ( ) => {
2645
+ to (
2646
+ {
2647
+ type : 'list' ,
2648
+ ordered : true ,
2649
+ children : [ { type : 'listItem' , children : [ ] } ]
2650
+ } ,
2651
+ // @ts -expect-error: runtime.
2652
+ { bulletOrdered : '~' }
2653
+ )
2654
+ } ,
2655
+ / C a n n o t s e r i a l i z e i t e m s w i t h ` ~ ` f o r ` o p t i o n s .b u l l e t O r d e r e d ` / ,
2656
+ 'should throw on a `bulletOrdered` that is invalid'
2657
+ )
2658
+
2659
+ t . equal (
2660
+ to (
2661
+ {
2662
+ type : 'root' ,
2663
+ children : [
2664
+ {
2665
+ type : 'list' ,
2666
+ ordered : true ,
2667
+ children : [ { type : 'listItem' , children : [ ] } ]
2668
+ } ,
2669
+ {
2670
+ type : 'list' ,
2671
+ ordered : true ,
2672
+ children : [ { type : 'listItem' , children : [ ] } ]
2673
+ }
2674
+ ]
2675
+ } ,
2676
+ { bulletOrdered : '.' , bulletOrderedOther : ')' }
2677
+ ) ,
2678
+ '1.\n\n1)\n' ,
2679
+ 'should support `bulletOrderedOther`'
2680
+ )
2681
+
2682
+ t . throws (
2683
+ ( ) => {
2684
+ to (
2685
+ {
2686
+ type : 'list' ,
2687
+ ordered : true ,
2688
+ children : [ { type : 'listItem' , children : [ ] } ]
2689
+ } ,
2690
+ // @ts -expect-error: runtime.
2691
+ { bulletOrderedOther : '~' }
2692
+ )
2693
+ } ,
2694
+ / C a n n o t s e r i a l i z e i t e m s w i t h ` ~ ` f o r ` o p t i o n s .b u l l e t O r d e r e d O t h e r ` / ,
2695
+ 'should throw on a `bulletOrderedOther` that is invalid'
2696
+ )
2697
+
2698
+ t . throws (
2699
+ ( ) => {
2700
+ to (
2701
+ {
2702
+ type : 'root' ,
2703
+ children : [
2704
+ {
2705
+ type : 'list' ,
2706
+ ordered : true ,
2707
+ children : [ { type : 'listItem' , children : [ ] } ]
2708
+ } ,
2709
+ {
2710
+ type : 'list' ,
2711
+ ordered : true ,
2712
+ children : [ { type : 'listItem' , children : [ ] } ]
2713
+ }
2714
+ ]
2715
+ } ,
2716
+ { bulletOrdered : '.' , bulletOrderedOther : '.' }
2717
+ )
2718
+ } ,
2719
+ / E x p e c t e d ` b u l l e t O r d e r e d ` \( ` .` \) a n d ` b u l l e t O r d e r e d O t h e r ` \( ` .` \) t o b e d i f f e r e n t / ,
2720
+ 'should throw on a `bulletOrderedOther` that matches `bulletOrdered`'
2721
+ )
2722
+
2630
2723
t . end ( )
2631
2724
} )
2632
2725
@@ -3318,5 +3411,82 @@ test('roundtrip', (t) => {
3318
3411
'should roundtrip different lists w/ `bulletOther` and lists that could turn into thematic breaks (6)'
3319
3412
)
3320
3413
3414
+ tree = from ( '1. a\n1) b' )
3415
+
3416
+ t . deepEqual (
3417
+ removePosition ( tree , true ) ,
3418
+ removePosition (
3419
+ from ( to ( tree , { bulletOrdered : '.' , bulletOrderedOther : ')' } ) ) ,
3420
+ true
3421
+ ) ,
3422
+ 'should roundtrip different lists w/ `bulletOrderedOther`'
3423
+ )
3424
+
3425
+ tree = from ( '1. ---\n1) 1. 1)\n1. b' )
3426
+
3427
+ t . deepEqual (
3428
+ removePosition ( tree , true ) ,
3429
+ removePosition (
3430
+ from ( to ( tree , { bulletOrdered : '.' , bulletOrderedOther : ')' } ) ) ,
3431
+ true
3432
+ ) ,
3433
+ 'should roundtrip different lists w/ `bulletOrderedOther` and lists that could turn into thematic breaks (1)'
3434
+ )
3435
+
3436
+ tree = from ( '1. 1. 1)\n1) ---\n1. b' )
3437
+
3438
+ t . deepEqual (
3439
+ removePosition ( tree , true ) ,
3440
+ removePosition (
3441
+ from ( to ( tree , { bulletOrdered : '.' , bulletOrderedOther : ')' } ) ) ,
3442
+ true
3443
+ ) ,
3444
+ 'should roundtrip different lists w/ `bulletOrderedOther` and lists that could turn into thematic breaks (2)'
3445
+ )
3446
+
3447
+ tree = from ( '1. 1. 1)\n1. 1.' )
3448
+
3449
+ t . deepEqual (
3450
+ removePosition ( tree , true ) ,
3451
+ removePosition (
3452
+ from ( to ( tree , { bulletOrdered : '.' , bulletOrderedOther : ')' } ) ) ,
3453
+ true
3454
+ ) ,
3455
+ 'should roundtrip different lists w/ `bulletOrderedOther` and lists that could turn into thematic breaks (3)'
3456
+ )
3457
+
3458
+ tree = from ( '1. 1) 1.\n 1.\n 1)\n 1.' )
3459
+
3460
+ t . deepEqual (
3461
+ removePosition ( tree , true ) ,
3462
+ removePosition (
3463
+ from ( to ( tree , { bulletOrdered : '.' , bulletOrderedOther : ')' } ) ) ,
3464
+ true
3465
+ ) ,
3466
+ 'should roundtrip different lists w/ `bulletOrderedOther` and lists that could turn into thematic breaks (4)'
3467
+ )
3468
+
3469
+ tree = from ( '1. 1) 1.\n 1) 1.\n 1)\n 1.' )
3470
+
3471
+ t . deepEqual (
3472
+ removePosition ( tree , true ) ,
3473
+ removePosition (
3474
+ from ( to ( tree , { bulletOrdered : '.' , bulletOrderedOther : ')' } ) ) ,
3475
+ true
3476
+ ) ,
3477
+ 'should roundtrip different lists w/ `bulletOrderedOther` and lists that could turn into thematic breaks (5)'
3478
+ )
3479
+
3480
+ tree = from ( '1. 1)\n1. 1.\n 1)\n 1.' )
3481
+
3482
+ t . deepEqual (
3483
+ removePosition ( tree , true ) ,
3484
+ removePosition (
3485
+ from ( to ( tree , { bulletOrdered : '.' , bulletOrderedOther : ')' } ) ) ,
3486
+ true
3487
+ ) ,
3488
+ 'should roundtrip different lists w/ `bulletOrderedOther` and lists that could turn into thematic breaks (6)'
3489
+ )
3490
+
3321
3491
t . end ( )
3322
3492
} )
0 commit comments