@@ -211,4 +211,56 @@ describe('Trigger.Unique', () => {
211211 expect ( uniqueBody ) . toBeTruthy ( ) ;
212212 expect ( uniqueBody . className ) . not . toContain ( 'undefined' ) ;
213213 } ) ;
214+
215+ it ( 'should combine alignedClassName with uniqueBgClassName' , async ( ) => {
216+ const getPopupClassNameFromAlign = ( align : any ) => {
217+ return `custom-align-${ align . points ?. [ 0 ] || 'default' } ` ;
218+ } ;
219+
220+ const { container } = render (
221+ < UniqueProvider >
222+ < Trigger
223+ action = { [ 'click' ] }
224+ popup = { < strong className = "x-content" > tooltip</ strong > }
225+ unique
226+ popupPlacement = "bottomLeft"
227+ builtinPlacements = { {
228+ bottomLeft : {
229+ points : [ 'tl' , 'bl' ] ,
230+ offset : [ 0 , 4 ] ,
231+ overflow : {
232+ adjustX : 0 ,
233+ adjustY : 1 ,
234+ } ,
235+ } ,
236+ } }
237+ getPopupClassNameFromAlign = { getPopupClassNameFromAlign }
238+ uniqueBgClassName = "custom-bg-class"
239+ >
240+ < div className = "target" > click me</ div >
241+ </ Trigger >
242+ </ UniqueProvider > ,
243+ ) ;
244+
245+ // Initially no popup should be visible
246+ expect ( document . querySelector ( '.rc-trigger-popup' ) ) . toBeFalsy ( ) ;
247+
248+ // Click trigger to show popup
249+ fireEvent . click ( container . querySelector ( '.target' ) ) ;
250+ await awaitFakeTimer ( ) ;
251+
252+ // Wait a bit more for alignment to complete
253+ await awaitFakeTimer ( ) ;
254+
255+ // Check that popup exists
256+ const popup = document . querySelector ( '.rc-trigger-popup' ) ;
257+ expect ( popup ) . toBeTruthy ( ) ;
258+ expect ( popup . querySelector ( '.x-content' ) . textContent ) . toBe ( 'tooltip' ) ;
259+
260+ // Check that both custom background className and aligned className are applied to UniqueBody
261+ const uniqueBody = document . querySelector ( '.rc-trigger-popup-unique-body' ) ;
262+ expect ( uniqueBody ) . toBeTruthy ( ) ;
263+ expect ( uniqueBody . className ) . toContain ( 'custom-bg-class' ) ;
264+ expect ( uniqueBody . className ) . toContain ( 'custom-align' ) ;
265+ } ) ;
214266} ) ;
0 commit comments