@@ -388,7 +388,7 @@ describe('documentState', () => {
388
388
const documentState : DocumentState = {
389
389
...createDocumentState ( { json, expand : ( ) => true } ) ,
390
390
visibleSectionsMap : {
391
- '/members' : [ { start : 0 , end : 2 } ]
391
+ '/members' : [ { start : 0 , end : 3 } ]
392
392
}
393
393
}
394
394
@@ -463,7 +463,7 @@ describe('documentState', () => {
463
463
'/members/3' : true
464
464
} ,
465
465
visibleSectionsMap : {
466
- '/members' : [ { start : 0 , end : 3 } ]
466
+ '/members' : [ { start : 0 , end : 4 } ]
467
467
}
468
468
} )
469
469
} )
@@ -492,7 +492,7 @@ describe('documentState', () => {
492
492
'' : true
493
493
} ,
494
494
visibleSectionsMap : {
495
- '' : [ { start : 0 , end : 4 } ]
495
+ '' : [ { start : 0 , end : 5 } ]
496
496
}
497
497
}
498
498
@@ -501,7 +501,7 @@ describe('documentState', () => {
501
501
assert . deepStrictEqual ( res . documentState , {
502
502
...documentState ,
503
503
visibleSectionsMap : {
504
- '' : [ { start : 0 , end : 5 } ]
504
+ '' : [ { start : 0 , end : 6 } ]
505
505
}
506
506
} )
507
507
} )
@@ -548,7 +548,7 @@ describe('documentState', () => {
548
548
...documentState ,
549
549
expandedMap : deleteIn ( documentState . expandedMap , [ '/members/2' ] ) , // [2] is moved to [1]
550
550
visibleSectionsMap : {
551
- '/members' : [ { start : 0 , end : 1 } ]
551
+ '/members' : [ { start : 0 , end : 2 } ]
552
552
}
553
553
} )
554
554
} )
@@ -565,7 +565,7 @@ describe('documentState', () => {
565
565
...documentState ,
566
566
expandedMap : deleteIn ( documentState . expandedMap , [ '/members/2' ] ) , // [2] is moved to [1]
567
567
visibleSectionsMap : {
568
- '/members' : [ { start : 0 , end : 1 } ]
568
+ '/members' : [ { start : 0 , end : 2 } ]
569
569
}
570
570
} )
571
571
} )
@@ -722,7 +722,7 @@ describe('documentState', () => {
722
722
'/members/3' : true
723
723
} ,
724
724
visibleSectionsMap : {
725
- '/members' : [ { start : 0 , end : 3 } ]
725
+ '/members' : [ { start : 0 , end : 4 } ]
726
726
}
727
727
} )
728
728
} )
@@ -871,7 +871,7 @@ describe('documentState', () => {
871
871
'/members/3' : true
872
872
} ,
873
873
visibleSectionsMap : {
874
- '/members' : [ { start : 0 , end : 3 } ]
874
+ '/members' : [ { start : 0 , end : 4 } ]
875
875
}
876
876
} )
877
877
} )
@@ -907,7 +907,7 @@ describe('documentState', () => {
907
907
'/members/1' : true
908
908
} ,
909
909
visibleSectionsMap : {
910
- '/members' : [ { start : 0 , end : 1 } ]
910
+ '/members' : [ { start : 0 , end : 2 } ]
911
911
}
912
912
} )
913
913
} )
@@ -940,7 +940,7 @@ describe('documentState', () => {
940
940
941
941
test ( 'should insert at the end of a visible section' , ( ) => {
942
942
assert . deepStrictEqual ( shiftVisibleSections ( visibleSections , 2 , 1 ) , [
943
- { start : 0 , end : 3 } ,
943
+ { start : 0 , end : 2 } ,
944
944
{ start : 5 , end : 7 }
945
945
] )
946
946
} )
@@ -959,12 +959,37 @@ describe('documentState', () => {
959
959
] )
960
960
} )
961
961
962
- test ( 'should remove at the end of a visible section' , ( ) => {
962
+ test ( 'should remove inside an invisible section (start) ' , ( ) => {
963
963
assert . deepStrictEqual ( shiftVisibleSections ( visibleSections , 2 , - 1 ) , [
964
- { start : 0 , end : 1 } ,
964
+ { start : 0 , end : 2 } ,
965
965
{ start : 3 , end : 5 }
966
966
] )
967
967
} )
968
+
969
+ test ( 'should remove inside an invisible section (middle)' , ( ) => {
970
+ assert . deepStrictEqual ( shiftVisibleSections ( visibleSections , 3 , - 1 ) , [
971
+ { start : 0 , end : 2 } ,
972
+ { start : 3 , end : 5 }
973
+ ] )
974
+ } )
975
+
976
+ test ( 'should remove inside an invisible section (end)' , ( ) => {
977
+ assert . deepStrictEqual ( shiftVisibleSections ( visibleSections , 4 , - 1 ) , [
978
+ { start : 0 , end : 2 } ,
979
+ { start : 4 , end : 5 }
980
+ ] )
981
+ } )
982
+
983
+ test ( 'should merge visible sections when adjacent' , ( ) => {
984
+ const visibleSections2 = [
985
+ { start : 0 , end : 100 } ,
986
+ { start : 200 , end : 300 }
987
+ ]
988
+
989
+ assert . deepStrictEqual ( shiftVisibleSections ( visibleSections2 , 100 , - 100 ) , [
990
+ { start : 0 , end : 200 }
991
+ ] )
992
+ } )
968
993
} )
969
994
970
995
describe ( 'expandPath' , ( ) => {
0 commit comments