@@ -679,7 +679,7 @@ describe('a generate json patch function', () => {
679
679
} ,
680
680
} ;
681
681
682
- it ( 'detects changes as a given depth of 3' , ( ) => {
682
+ it ( 'detects changes at a given depth of 3' , ( ) => {
683
683
const patch = generateJSONPatch ( before , after , { maxDepth : 3 } ) ;
684
684
expect ( patch ) . to . eql ( [
685
685
{
@@ -737,7 +737,7 @@ describe('a generate json patch function', () => {
737
737
expect ( patch ) . to . eql ( [ ] ) ;
738
738
} ) ;
739
739
740
- it ( 'detects changes as a given depth of 4' , ( ) => {
740
+ it ( 'detects changes at a given depth of 4' , ( ) => {
741
741
const afterModified = structuredClone ( after ) ;
742
742
afterModified . firstLevel . secondLevel . thirdLevelTwo = 'hello-world' ;
743
743
const patch = generateJSONPatch ( before , afterModified , { maxDepth : 4 } ) ;
@@ -757,7 +757,7 @@ describe('a generate json patch function', () => {
757
757
] ) ;
758
758
} ) ;
759
759
760
- it ( 'detects changes as a given depth of 4 for an array value' , ( ) => {
760
+ it ( 'detects changes at a given depth of 4 for an array value' , ( ) => {
761
761
const afterModified = structuredClone ( before ) ;
762
762
afterModified . firstLevel . secondLevel . thirdLevelThree = [ 'test' ] ;
763
763
const patch = generateJSONPatch ( before , afterModified , { maxDepth : 4 } ) ;
@@ -770,7 +770,7 @@ describe('a generate json patch function', () => {
770
770
] ) ;
771
771
} ) ;
772
772
773
- it ( 'detects changes as a given depth of 4 for an removed array value' , ( ) => {
773
+ it ( 'detects changes as a given depth of 4 for a removed array value' , ( ) => {
774
774
const afterModified = structuredClone ( before ) ;
775
775
// @ts -ignore
776
776
delete afterModified . firstLevel . secondLevel . thirdLevelThree ;
@@ -783,7 +783,7 @@ describe('a generate json patch function', () => {
783
783
] ) ;
784
784
} ) ;
785
785
786
- it ( 'detects changes as a given depth of 4 for an nullyfied array value' , ( ) => {
786
+ it ( 'detects changes as a given depth of 4 for a nullyfied array value' , ( ) => {
787
787
const afterModified = structuredClone ( before ) ;
788
788
// @ts -ignore
789
789
afterModified . firstLevel . secondLevel . thirdLevelThree = null ;
@@ -796,6 +796,33 @@ describe('a generate json patch function', () => {
796
796
} ,
797
797
] ) ;
798
798
} ) ;
799
+
800
+ it ( 'ignores key order on objects when comparing at max depth' , ( ) => {
801
+ const before = {
802
+ a : {
803
+ b : {
804
+ c : {
805
+ d : 'hello' ,
806
+ e : 'world' ,
807
+ } ,
808
+ } ,
809
+ } ,
810
+ } ;
811
+
812
+ const after = {
813
+ a : {
814
+ b : {
815
+ c : {
816
+ e : 'world' ,
817
+ d : 'hello' ,
818
+ } ,
819
+ } ,
820
+ } ,
821
+ } ;
822
+
823
+ const patch = generateJSONPatch ( before , after , { maxDepth : 1 } ) ;
824
+ expect ( patch ) . to . eql ( [ ] ) ;
825
+ } ) ;
799
826
} ) ;
800
827
} ) ;
801
828
0 commit comments