Skip to content

Commit 5109394

Browse files
committed
test: add test case
1 parent b1d0967 commit 5109394

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/align.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,41 @@ describe('Trigger.Align', () => {
296296
top: `56px`,
297297
});
298298
});
299+
300+
it('both adjustX and adjustY should get correct points', async () => {
301+
// Set target position to top left corner to force flip to bottom right
302+
rectX = 0;
303+
rectY = 0;
304+
rectWidth = 100;
305+
rectHeight = 100;
306+
307+
const onPopupAlign = jest.fn();
308+
309+
render(
310+
<Trigger
311+
popupVisible
312+
popup={<span className="bamboo" />}
313+
popupAlign={{
314+
points: ['tl', 'bl'],
315+
overflow: {
316+
adjustX: true,
317+
adjustY: true,
318+
},
319+
}}
320+
onPopupAlign={onPopupAlign}
321+
>
322+
<div />
323+
</Trigger>,
324+
);
325+
326+
await awaitFakeTimer();
327+
328+
// Check that the points have been flipped correctly
329+
expect(onPopupAlign).toHaveBeenCalledWith(
330+
expect.anything(),
331+
expect.objectContaining({
332+
points: ['br', 'tr'],
333+
}),
334+
);
335+
});
299336
});

0 commit comments

Comments
 (0)