File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -53,5 +53,12 @@ describe('typeOf', () => {
5353 type : is . StrictMode
5454 } )
5555 ) . toBe ( REACT_STRICT_MODE_TYPE )
56+
57+ expect (
58+ typeOf ( {
59+ $$typeof : is . Element ,
60+ type : is . Suspense
61+ } )
62+ ) . toBe ( REACT_SUSPENSE_TYPE )
5663 } )
5764} )
Original file line number Diff line number Diff line change 11import React , {
22 Component ,
33 Fragment ,
4+ Suspense ,
5+ StrictMode ,
6+ unstable_Profiler as Profiler ,
7+ unstable_ConcurrentMode as AsyncMode ,
48 createContext ,
59 useReducer ,
610 useContext ,
@@ -57,6 +61,36 @@ describe('visitElement', () => {
5761 expect ( children [ 1 ] . type ) . toBe ( Noop )
5862 } )
5963
64+ it ( 'walks misc. mode-like components' , ( ) => {
65+ const assert = element => {
66+ const children = visitElement ( element , [ ] , ( ) => { } )
67+ expect ( children . length ) . toBe ( 1 )
68+ expect ( children [ 0 ] . type ) . toBe ( Noop )
69+ }
70+
71+ assert (
72+ < Suspense fallback = { null } >
73+ < Noop />
74+ </ Suspense >
75+ )
76+
77+ assert (
78+ < StrictMode >
79+ < Noop />
80+ </ StrictMode >
81+ )
82+ assert (
83+ < AsyncMode >
84+ < Noop />
85+ </ AsyncMode >
86+ )
87+ assert (
88+ < Profiler >
89+ < Noop />
90+ </ Profiler >
91+ )
92+ } )
93+
6094 it ( 'walks DOM elements' , ( ) => {
6195 const element = (
6296 < div >
@@ -98,7 +132,7 @@ describe('visitElement', () => {
98132 expect ( leaf ) . toHaveBeenCalledWith ( 'testB' )
99133 } )
100134
101- it ( 'skipvs over invalid Consumer components' , ( ) => {
135+ it ( 'skips over invalid Consumer components' , ( ) => {
102136 const Context = createContext ( 'default' )
103137 const children = visitElement ( < Context . Consumer /> , [ ] , ( ) => { } )
104138 expect ( children . length ) . toBe ( 0 )
You can’t perform that action at this time.
0 commit comments