Skip to content

Commit e65ce77

Browse files
committed
test: simplify test case
1 parent aac9d88 commit e65ce77

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

tests/unique.test.tsx

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ describe('Trigger.Unique', () => {
125125

126126
// There should only be one popup element
127127
expect(document.querySelectorAll('.rc-trigger-popup').length).toBe(1);
128-
expect(document.querySelectorAll('.rc-trigger-popup-unique-body').length).toBe(
129-
1,
130-
);
128+
expect(
129+
document.querySelectorAll('.rc-trigger-popup-unique-body').length,
130+
).toBe(1);
131131

132132
// FloatBg open prop should not have changed during transition (no close animation)
133133
expect(global.openChangeLog).toHaveLength(0);
@@ -192,7 +192,9 @@ describe('Trigger.Unique', () => {
192192
});
193193

194194
it('should apply uniqueBgStyle to UniqueBody component', async () => {
195-
await setupAndOpenPopup({ uniqueBgStyle: { backgroundColor: 'red', border: '1px solid blue' } });
195+
await setupAndOpenPopup({
196+
uniqueBgStyle: { backgroundColor: 'red', border: '1px solid blue' },
197+
});
196198

197199
// Check that UniqueBody has the custom background style
198200
const uniqueBody = document.querySelector('.rc-trigger-popup-unique-body');
@@ -213,17 +215,17 @@ describe('Trigger.Unique', () => {
213215
});
214216

215217
it('should combine alignedClassName with uniqueBgClassName', async () => {
216-
const getPopupClassNameFromAlign = (align: any) => {
217-
return `custom-align-${align.points?.[0] || 'default'}`;
218-
};
218+
const getPopupClassNameFromAlign = () => 'bamboo';
219219

220-
const { container } = render(
220+
render(
221221
<UniqueProvider>
222222
<Trigger
223223
action={['click']}
224224
popup={<strong className="x-content">tooltip</strong>}
225225
unique
226+
popupVisible
226227
popupPlacement="bottomLeft"
228+
getPopupClassNameFromAlign={getPopupClassNameFromAlign}
227229
builtinPlacements={{
228230
bottomLeft: {
229231
points: ['tl', 'bl'],
@@ -234,33 +236,15 @@ describe('Trigger.Unique', () => {
234236
},
235237
},
236238
}}
237-
getPopupClassNameFromAlign={getPopupClassNameFromAlign}
238-
uniqueBgClassName="custom-bg-class"
239239
>
240240
<div className="target">click me</div>
241241
</Trigger>
242242
</UniqueProvider>,
243243
);
244244

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');
245+
expect(document.querySelector('.rc-trigger-popup')).toHaveClass('bamboo');
246+
expect(document.querySelector('.rc-trigger-popup-unique-body')).toHaveClass(
247+
'bamboo',
248+
);
265249
});
266250
});

0 commit comments

Comments
 (0)