File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -138,4 +138,56 @@ describe('BaseSelect', () => {
138138
139139 expect ( container . querySelector ( '.rc-select-dropdown-placement-fallback' ) ) . toBeTruthy ( ) ;
140140 } ) ;
141+
142+ it ( 'should use RootComponent when provided in components prop' , ( ) => {
143+ const CustomRoot = forwardRef < HTMLDivElement > ( ( props , ref ) => (
144+ < div ref = { ref } className = "custom-root" { ...props } />
145+ ) ) ;
146+
147+ const { container } = render (
148+ < BaseSelect
149+ prefixCls = "rc-select"
150+ id = "test"
151+ displayValues = { [ ] }
152+ onDisplayValuesChange = { ( ) => { } }
153+ searchValue = ""
154+ onSearch = { ( ) => { } }
155+ OptionList = { OptionList }
156+ emptyOptions
157+ components = { {
158+ root : CustomRoot ,
159+ } }
160+ /> ,
161+ ) ;
162+
163+ expect ( container . querySelector ( '.custom-root' ) ) . toBeTruthy ( ) ;
164+ expect ( container . querySelector ( '.rc-select' ) ) . toBeFalsy ( ) ;
165+ } ) ;
166+
167+ it ( 'should use React element as RootComponent when provided in components prop' , ( ) => {
168+ const CustomRoot = forwardRef < HTMLDivElement > ( ( props , ref ) => (
169+ < div ref = { ref } className = "custom-root-element" { ...props } />
170+ ) ) ;
171+
172+ const customElement = < CustomRoot /> ;
173+
174+ const { container } = render (
175+ < BaseSelect
176+ prefixCls = "rc-select"
177+ id = "test"
178+ displayValues = { [ ] }
179+ onDisplayValuesChange = { ( ) => { } }
180+ searchValue = ""
181+ onSearch = { ( ) => { } }
182+ OptionList = { OptionList }
183+ emptyOptions
184+ components = { {
185+ root : customElement ,
186+ } }
187+ /> ,
188+ ) ;
189+
190+ expect ( container . querySelector ( '.custom-root-element' ) ) . toBeTruthy ( ) ;
191+ expect ( container . querySelector ( '.rc-select' ) ) . toBeFalsy ( ) ;
192+ } ) ;
141193} ) ;
You can’t perform that action at this time.
0 commit comments