@@ -161,18 +161,89 @@ describe('Trigger.Unique', () => {
161
161
popup = { < strong className = "x-content" > tooltip</ strong > }
162
162
unique
163
163
uniqueBgClassName = "custom-bg-class"
164
- popupVisible
165
164
>
166
165
< div className = "target" > click me</ div >
167
166
</ Trigger >
168
167
</ UniqueProvider > ,
169
168
) ;
170
169
170
+ // Initially no popup should be visible
171
+ expect ( document . querySelector ( '.rc-trigger-popup' ) ) . toBeFalsy ( ) ;
172
+
173
+ // Click trigger to show popup
174
+ fireEvent . click ( container . querySelector ( '.target' ) ) ;
171
175
await awaitFakeTimer ( ) ;
172
176
177
+ // Check that popup exists
178
+ const popup = document . querySelector ( '.rc-trigger-popup' ) ;
179
+ expect ( popup ) . toBeTruthy ( ) ;
180
+
173
181
// Check that FloatBg has the custom background className
174
182
const floatBg = document . querySelector ( '.rc-trigger-popup-float-bg' ) ;
175
183
expect ( floatBg ) . toBeTruthy ( ) ;
176
- expect ( floatBg ) . toHaveClass ( 'custom-bg-class' ) ;
184
+ expect ( floatBg . className ) . toContain ( 'custom-bg-class' ) ;
185
+ } ) ;
186
+
187
+ it ( 'should apply uniqueBgStyle to FloatBg component' , async ( ) => {
188
+ const { container } = render (
189
+ < UniqueProvider >
190
+ < Trigger
191
+ action = { [ 'click' ] }
192
+ popup = { < strong className = "x-content" > tooltip</ strong > }
193
+ unique
194
+ uniqueBgStyle = { { backgroundColor : 'red' , border : '1px solid blue' } }
195
+ >
196
+ < div className = "target" > click me</ div >
197
+ </ Trigger >
198
+ </ UniqueProvider > ,
199
+ ) ;
200
+
201
+ // Initially no popup should be visible
202
+ expect ( document . querySelector ( '.rc-trigger-popup' ) ) . toBeFalsy ( ) ;
203
+
204
+ // Click trigger to show popup
205
+ fireEvent . click ( container . querySelector ( '.target' ) ) ;
206
+ await awaitFakeTimer ( ) ;
207
+
208
+ // Check that popup exists
209
+ const popup = document . querySelector ( '.rc-trigger-popup' ) ;
210
+ expect ( popup ) . toBeTruthy ( ) ;
211
+
212
+ // Check that FloatBg has the custom background style
213
+ const floatBg = document . querySelector ( '.rc-trigger-popup-float-bg' ) ;
214
+ expect ( floatBg ) . toBeTruthy ( ) ;
215
+ const computedStyle = window . getComputedStyle ( floatBg ) ;
216
+ expect ( computedStyle . backgroundColor ) . toBe ( 'red' ) ;
217
+ expect ( computedStyle . border ) . toContain ( '1px solid blue' ) ;
218
+ } ) ;
219
+
220
+ it ( 'should not apply any additional className to FloatBg when uniqueBgClassName is not provided' , async ( ) => {
221
+ const { container } = render (
222
+ < UniqueProvider >
223
+ < Trigger
224
+ action = { [ 'click' ] }
225
+ popup = { < strong className = "x-content" > tooltip</ strong > }
226
+ unique
227
+ >
228
+ < div className = "target" > click me</ div >
229
+ </ Trigger >
230
+ </ UniqueProvider > ,
231
+ ) ;
232
+
233
+ // Initially no popup should be visible
234
+ expect ( document . querySelector ( '.rc-trigger-popup' ) ) . toBeFalsy ( ) ;
235
+
236
+ // Click trigger to show popup
237
+ fireEvent . click ( container . querySelector ( '.target' ) ) ;
238
+ await awaitFakeTimer ( ) ;
239
+
240
+ // Check that popup exists
241
+ const popup = document . querySelector ( '.rc-trigger-popup' ) ;
242
+ expect ( popup ) . toBeTruthy ( ) ;
243
+
244
+ // Check that FloatBg exists but does not have custom background className
245
+ const floatBg = document . querySelector ( '.rc-trigger-popup-float-bg' ) ;
246
+ expect ( floatBg ) . toBeTruthy ( ) ;
247
+ expect ( floatBg . className ) . not . toContain ( 'undefined' ) ;
177
248
} ) ;
178
249
} ) ;
0 commit comments