Skip to content

Commit 17bc733

Browse files
committed
Add unit test
1 parent 9493212 commit 17bc733

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

packages/eui/src/components/flyout/flyout.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,51 @@ describe('EuiFlyout', () => {
437437
});
438438
});
439439

440+
describe('push padding manager state coordination', () => {
441+
it('applies body padding for push flyouts', () => {
442+
const { container } = render(
443+
<EuiFlyout
444+
onClose={() => {}}
445+
type="push"
446+
pushMinBreakpoint="xs"
447+
data-test-subj="push-flyout"
448+
/>
449+
);
450+
451+
const flyout = container.querySelector('[data-test-subj="push-flyout"]');
452+
expect(flyout).toBeInTheDocument();
453+
454+
// Body should have padding applied
455+
const bodyPaddingEnd = document.body.style.paddingInlineEnd;
456+
expect(bodyPaddingEnd).toBeTruthy();
457+
});
458+
459+
it('removes body padding on unmount', () => {
460+
const { unmount } = render(
461+
<EuiFlyout
462+
onClose={() => {}}
463+
type="push"
464+
pushMinBreakpoint="xs"
465+
data-test-subj="push-flyout"
466+
/>
467+
);
468+
469+
// Verify padding was applied
470+
expect(document.body.style.paddingInlineEnd).toBeTruthy();
471+
472+
unmount();
473+
474+
// Verify padding was cleared
475+
expect(document.body.style.paddingInlineEnd).toBe('');
476+
});
477+
478+
afterEach(() => {
479+
// Clean up body styles after each test
480+
document.body.style.paddingInlineStart = '';
481+
document.body.style.paddingInlineEnd = '';
482+
});
483+
});
484+
440485
describe('flyout routing logic', () => {
441486
it('routes to child flyout when session is undefined and there is an active session', () => {
442487
// First render with just the main flyout to establish a session

0 commit comments

Comments
 (0)