@@ -10,6 +10,8 @@ describe('AugmentObject', () => {
10
10
11
11
const augmentedObject = augmentArray ( originalObject ) ;
12
12
13
+ expect ( augmentedObject . constructor . name ) . toEqual ( 'Array' ) ;
14
+
13
15
expect ( augmentedObject . push ( 5 ) ) . toEqual ( 6 ) ;
14
16
expect ( augmentedObject ) . toEqual ( [ 1 , 2 , 3 , 4 , null , 5 ] ) ;
15
17
expect ( originalObject ) . toEqual ( copyOriginal ) ;
@@ -207,6 +209,8 @@ describe('AugmentObject', () => {
207
209
208
210
const augmentedObject = augmentObject ( originalObject ) ;
209
211
212
+ expect ( augmentedObject . constructor . name ) . toEqual ( 'Object' ) ;
213
+
210
214
augmentedObject [ 1 ] = 911 ;
211
215
expect ( originalObject [ 1 ] ) . toEqual ( 11 ) ;
212
216
expect ( augmentedObject [ 1 ] ) . toEqual ( 911 ) ;
@@ -589,5 +593,29 @@ describe('AugmentObject', () => {
589
593
delete augmentedObject . toString ;
590
594
expect ( augmentedObject . toString ) . toBeUndefined ( ) ;
591
595
} ) ;
596
+
597
+ test ( 'should handle constructor property correctly' , ( ) => {
598
+ const originalObject : any = {
599
+ a : {
600
+ b : {
601
+ c : {
602
+ d : '4' ,
603
+ } ,
604
+ } ,
605
+ } ,
606
+ } ;
607
+ const augmentedObject = augmentObject ( originalObject ) ;
608
+
609
+ expect ( augmentedObject . constructor . name ) . toEqual ( 'Object' ) ;
610
+ expect ( augmentedObject . a . constructor . name ) . toEqual ( 'Object' ) ;
611
+ expect ( augmentedObject . a . b . constructor . name ) . toEqual ( 'Object' ) ;
612
+ expect ( augmentedObject . a . b . c . constructor . name ) . toEqual ( 'Object' ) ;
613
+
614
+ augmentedObject . constructor = { } ;
615
+ expect ( augmentedObject . constructor . name ) . toEqual ( 'Object' ) ;
616
+
617
+ delete augmentedObject . constructor ;
618
+ expect ( augmentedObject . constructor . name ) . toEqual ( 'Object' ) ;
619
+ } ) ;
592
620
} ) ;
593
621
} ) ;
0 commit comments