File tree 1 file changed +42
-17
lines changed
1 file changed +42
-17
lines changed Original file line number Diff line number Diff line change @@ -44,23 +44,48 @@ describe('sortObject', () => {
44
44
} ) ;
45
45
} ) ;
46
46
47
- it ( 'should remove _owner key from react elements' , ( ) => {
48
- const fixture = {
49
- _owner : "_owner that doesn't belong to react element" ,
50
- component : < div /> ,
51
- } ;
52
-
53
- expect ( JSON . stringify ( sortObject ( fixture ) ) ) . toEqual (
54
- JSON . stringify ( {
47
+ describe ( '_owner key' , ( ) => {
48
+ it ( 'should preserve the _owner key for objects that are not react elements' , ( ) => {
49
+ const fixture = {
55
50
_owner : "_owner that doesn't belong to react element" ,
56
- component : {
57
- $$typeof : Symbol ( 'react.transitional.element' ) ,
58
- type : 'div' ,
59
- key : null ,
60
- props : { } ,
61
- _store : { } ,
62
- } ,
63
- } )
64
- ) ;
51
+ foo : 'bar' ,
52
+ } ;
53
+
54
+ expect ( JSON . stringify ( sortObject ( fixture ) ) ) . toEqual (
55
+ JSON . stringify ( {
56
+ _owner : "_owner that doesn't belong to react element" ,
57
+ foo : 'bar' ,
58
+ } )
59
+ ) ;
60
+ } ) ;
61
+
62
+ it ( 'should remove the _owner key from top level react element' , ( ) => {
63
+ const fixture = {
64
+ reactElement : (
65
+ < div >
66
+ < span > </ span >
67
+ </ div >
68
+ ) ,
69
+ } ;
70
+
71
+ expect ( JSON . stringify ( sortObject ( fixture ) ) ) . toEqual (
72
+ JSON . stringify ( {
73
+ reactElement : {
74
+ type : 'div' ,
75
+ key : null ,
76
+ props : {
77
+ children : {
78
+ type : 'span' ,
79
+ key : null ,
80
+ props : { } ,
81
+ _owner : null ,
82
+ _store : { } ,
83
+ } ,
84
+ } ,
85
+ _store : { } ,
86
+ } ,
87
+ } )
88
+ ) ;
89
+ } ) ;
65
90
} ) ;
66
91
} ) ;
You can’t perform that action at this time.
0 commit comments