@@ -537,10 +537,6 @@ describe('InspectedElementContext', () => {
537
537
xyz : 1 ,
538
538
} ,
539
539
} ) ;
540
- const objectWithNullProto = Object . create ( null ) ;
541
- objectWithNullProto . string = 'abc' ;
542
- objectWithNullProto . number = 123 ;
543
- objectWithNullProto . boolean = true ;
544
540
545
541
const container = document . createElement ( 'div' ) ;
546
542
await utils . actAsync ( ( ) =>
@@ -558,7 +554,6 @@ describe('InspectedElementContext', () => {
558
554
map = { mapShallow }
559
555
map_of_maps = { mapOfMaps }
560
556
object_of_objects = { objectOfObjects }
561
- object_with_null_proto = { objectWithNullProto }
562
557
react_element = { < span /> }
563
558
regexp = { / a b c / giu}
564
559
set = { setShallow }
@@ -609,7 +604,6 @@ describe('InspectedElementContext', () => {
609
604
map,
610
605
map_of_maps,
611
606
object_of_objects,
612
- object_with_null_proto,
613
607
react_element,
614
608
regexp,
615
609
set,
@@ -701,12 +695,6 @@ describe('InspectedElementContext', () => {
701
695
) ;
702
696
expect ( object_of_objects . inner [ meta . preview_short ] ) . toBe ( '{…}' ) ;
703
697
704
- expect ( object_with_null_proto ) . toEqual ( {
705
- boolean : true ,
706
- number : 123 ,
707
- string : 'abc' ,
708
- } ) ;
709
-
710
698
expect ( react_element [ meta . inspectable ] ) . toBe ( false ) ;
711
699
expect ( react_element [ meta . name ] ) . toBe ( 'span' ) ;
712
700
expect ( react_element [ meta . type ] ) . toBe ( 'react_element' ) ;
@@ -753,6 +741,101 @@ describe('InspectedElementContext', () => {
753
741
done ( ) ;
754
742
} ) ;
755
743
744
+ it ( 'should support objects with no prototype' , async done => {
745
+ const Example = ( ) => null ;
746
+
747
+ const object = Object . create ( null ) ;
748
+ object . string = 'abc' ;
749
+ object . number = 123 ;
750
+ object . boolean = true ;
751
+
752
+ const container = document . createElement ( 'div' ) ;
753
+ await utils . actAsync ( ( ) =>
754
+ ReactDOM . render ( < Example object = { object } /> , container ) ,
755
+ ) ;
756
+
757
+ const id = ( ( store . getElementIDAtIndex ( 0 ) : any ) : number ) ;
758
+
759
+ let inspectedElement = null ;
760
+
761
+ function Suspender ( { target} ) {
762
+ const { getInspectedElement} = React . useContext ( InspectedElementContext ) ;
763
+ inspectedElement = getInspectedElement ( id ) ;
764
+ return null ;
765
+ }
766
+
767
+ await utils . actAsync (
768
+ ( ) =>
769
+ TestRenderer . create (
770
+ < Contexts
771
+ defaultSelectedElementID = { id }
772
+ defaultSelectedElementIndex = { 0 } >
773
+ < React . Suspense fallback = { null } >
774
+ < Suspender target = { id } />
775
+ </ React . Suspense >
776
+ </ Contexts > ,
777
+ ) ,
778
+ false ,
779
+ ) ;
780
+
781
+ expect ( inspectedElement ) . not . toBeNull ( ) ;
782
+ expect ( inspectedElement ) . toMatchSnapshot ( `1: Inspected element ${ id } ` ) ;
783
+ expect ( inspectedElement . props . object ) . toEqual ( {
784
+ boolean : true ,
785
+ number : 123 ,
786
+ string : 'abc' ,
787
+ } ) ;
788
+
789
+ done ( ) ;
790
+ } ) ;
791
+
792
+ it ( 'should support objects with overridden hasOwnProperty' , async done => {
793
+ const Example = ( ) => null ;
794
+
795
+ const object = {
796
+ name : 'blah' ,
797
+ hasOwnProperty : true ,
798
+ } ;
799
+
800
+ const container = document . createElement ( 'div' ) ;
801
+ await utils . actAsync ( ( ) =>
802
+ ReactDOM . render ( < Example object = { object } /> , container ) ,
803
+ ) ;
804
+
805
+ const id = ( ( store . getElementIDAtIndex ( 0 ) : any ) : number ) ;
806
+
807
+ let inspectedElement = null ;
808
+
809
+ function Suspender ( { target} ) {
810
+ const { getInspectedElement} = React . useContext ( InspectedElementContext ) ;
811
+ inspectedElement = getInspectedElement ( id ) ;
812
+ return null ;
813
+ }
814
+
815
+ await utils . actAsync (
816
+ ( ) =>
817
+ TestRenderer . create (
818
+ < Contexts
819
+ defaultSelectedElementID = { id }
820
+ defaultSelectedElementIndex = { 0 } >
821
+ < React . Suspense fallback = { null } >
822
+ < Suspender target = { id } />
823
+ </ React . Suspense >
824
+ </ Contexts > ,
825
+ ) ,
826
+ false ,
827
+ ) ;
828
+
829
+ expect ( inspectedElement ) . not . toBeNull ( ) ;
830
+ expect ( inspectedElement ) . toMatchSnapshot ( `1: Inspected element ${ id } ` ) ;
831
+ expect ( inspectedElement . props . object ) . toEqual ( {
832
+ name : 'blah' ,
833
+ hasOwnProperty : true ,
834
+ } ) ;
835
+
836
+ done ( ) ;
837
+ } ) ;
838
+
756
839
it ( 'should support custom objects with enumerable properties and getters' , async done => {
757
840
class CustomData {
758
841
_number = 42 ;
0 commit comments