@@ -19,35 +19,31 @@ var emptyObject = require('emptyObject');
19
19
20
20
import type { TestRendererOptions } from 'ReactTestMount' ;
21
21
22
- var CONTAINER_TYPE = 'CONTAINER' ;
23
- var INSTANCE_TYPE = 'INSTANCE' ;
24
- var TEXT_TYPE = 'TEXT' ;
25
-
26
22
type ReactTestRendererJSON = { |
27
- type : string ,
28
- props : { [ propName : string ] : string } ,
29
- children : null | Array < string | ReactTestRendererJSON > ,
30
- $$typeof ?: any
23
+ type : string ,
24
+ props : { [ propName : string ] : string } ,
25
+ children : null | Array < string | ReactTestRendererJSON > ,
26
+ $$typeof ? : Symbol , // Optional because we add it with defineProperty().
31
27
| } ;
32
28
33
29
type Container = { |
34
- children : Array < Instance | TextInstance > ,
35
- createNodeMock : Function ,
36
- $$typeof : typeof CONTAINER_TYPE ,
30
+ children : Array < Instance | TextInstance > ,
31
+ createNodeMock : Function ,
32
+ $$typeof : 'CONTAINER' ,
37
33
| } ;
38
34
39
35
type Props = Object ;
40
36
type Instance = { |
41
- type : string ,
42
- props : Object ,
43
- children : Array < Instance | TextInstance > ,
44
- rootContainerInstance : Container ,
45
- $$typeof : typeof INSTANCE_TYPE ,
37
+ type : string ,
38
+ props : Object ,
39
+ children : Array < Instance | TextInstance > ,
40
+ rootContainerInstance : Container ,
41
+ $$typeof : 'INSTANCE' ,
46
42
| } ;
47
43
48
44
type TextInstance = { |
49
- text : string ,
50
- $$typeof : typeof TEXT_TYPE ,
45
+ text : string ,
46
+ $$typeof : 'TEXT' ,
51
47
| } ;
52
48
53
49
var TestRenderer = ReactFiberReconciler ( {
@@ -79,7 +75,7 @@ var TestRenderer = ReactFiberReconciler({
79
75
props,
80
76
children : [ ] ,
81
77
rootContainerInstance,
82
- $$typeof : INSTANCE_TYPE ,
78
+ $$typeof : 'INSTANCE' ,
83
79
} ;
84
80
85
81
return inst ;
@@ -150,7 +146,7 @@ var TestRenderer = ReactFiberReconciler({
150
146
) : TextInstance {
151
147
return {
152
148
text,
153
- $$typeof : TEXT_TYPE ,
149
+ $$typeof : 'TEXT' ,
154
150
} ;
155
151
} ,
156
152
@@ -197,12 +193,12 @@ var TestRenderer = ReactFiberReconciler({
197
193
198
194
getPublicInstance ( ref ) {
199
195
switch ( ref . $$typeof ) {
200
- case CONTAINER_TYPE :
196
+ case 'CONTAINER' :
201
197
return ref . createNodeMock ( ref . children [ 0 ] ) ;
202
- case INSTANCE_TYPE :
198
+ case 'INSTANCE' :
203
199
const createNodeMock = ref . rootContainerInstance . createNodeMock ;
204
200
return createNodeMock ( ref ) ;
205
- case TEXT_TYPE :
201
+ case 'TEXT' :
206
202
return ref . text ;
207
203
default :
208
204
throw new Error ( 'Attempted to getPublicInstance on an invalid ref.' ) ;
@@ -250,7 +246,7 @@ var ReactTestFiberRenderer = {
250
246
var container = {
251
247
children : [ ] ,
252
248
createNodeMock,
253
- $$typeof : CONTAINER_TYPE ,
249
+ $$typeof : 'CONTAINER' ,
254
250
} ;
255
251
var root = TestRenderer . createContainer ( container ) ;
256
252
TestRenderer . updateContainer ( element , root , null , null ) ;
0 commit comments