Skip to content

Commit 29ce8b9

Browse files
Adds Popover and Pane tests for the captureOverscroll prop
1 parent 1a5f94b commit 29ce8b9

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed

polaris-react/src/components/Popover/components/Pane/tests/Pane.test.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,54 @@ describe('<Pane />', () => {
153153
});
154154
});
155155
});
156+
157+
describe('captureOverscroll', () => {
158+
const Children = () => (
159+
<TextContainer>
160+
<p>Text</p>
161+
</TextContainer>
162+
);
163+
164+
describe('when not passed', () => {
165+
it('does not apply the Pane-captureOverscroll class', () => {
166+
const popoverPane = mountWithApp(
167+
<Pane>
168+
<Children />
169+
</Pane>,
170+
);
171+
172+
expect(popoverPane).toContainReactComponent(Scrollable, {
173+
className: 'Pane',
174+
});
175+
});
176+
});
177+
178+
describe('when passed as true', () => {
179+
it('applies the Pane-captureOverscroll class', () => {
180+
const popoverPane = mountWithApp(
181+
<Pane captureOverscroll>
182+
<Children />
183+
</Pane>,
184+
);
185+
186+
expect(popoverPane).toContainReactComponent(Scrollable, {
187+
className: 'Pane Pane-captureOverscroll',
188+
});
189+
});
190+
});
191+
192+
describe('when passed as false', () => {
193+
it('does not apply the Pane-captureOverscroll class', () => {
194+
const popoverPane = mountWithApp(
195+
<Pane captureOverscroll={false}>
196+
<Children />
197+
</Pane>,
198+
);
199+
200+
expect(popoverPane).toContainReactComponent(Scrollable, {
201+
className: 'Pane',
202+
});
203+
});
204+
});
205+
});
156206
});

polaris-react/src/components/Popover/tests/Popover.test.tsx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import {Portal} from '../../Portal';
55
import {PositionedOverlay} from '../../PositionedOverlay';
66
import {Popover} from '../Popover';
77
import type {PopoverPublicAPI} from '../Popover';
8-
import {PopoverOverlay} from '../components';
8+
import {Pane, PopoverOverlay} from '../components';
99
import * as setActivatorAttributes from '../set-activator-attributes';
10+
import {TextContainer} from '../../TextContainer';
1011

1112
describe('<Popover />', () => {
1213
const spy = jest.fn();
@@ -368,6 +369,64 @@ describe('<Popover />', () => {
368369
});
369370
});
370371
});
372+
373+
describe('captureOverscroll', () => {
374+
const TestActivator = <button>Activator</button>;
375+
376+
const Children = () => (
377+
<TextContainer>
378+
<p>Text</p>
379+
</TextContainer>
380+
);
381+
382+
const defaultProps = {
383+
active: true,
384+
activator: TestActivator,
385+
onClose: jest.fn(),
386+
};
387+
388+
describe('when not passed', () => {
389+
it('does not pass the prop as true to the Pane component', () => {
390+
const popover = mountWithApp(
391+
<Popover {...defaultProps}>
392+
<Children />
393+
</Popover>,
394+
);
395+
396+
expect(popover).toContainReactComponent(Pane, {
397+
captureOverscroll: undefined,
398+
});
399+
});
400+
});
401+
402+
describe('when passed as true', () => {
403+
it('passes the prop as true to the Pane component', () => {
404+
const popover = mountWithApp(
405+
<Popover {...defaultProps} captureOverscroll>
406+
<Children />
407+
</Popover>,
408+
);
409+
410+
expect(popover).toContainReactComponent(Pane, {
411+
captureOverscroll: true,
412+
});
413+
});
414+
});
415+
416+
describe('when passed as false', () => {
417+
it('passes the prop as false to the Pane component', () => {
418+
const popover = mountWithApp(
419+
<Popover {...defaultProps} captureOverscroll={false}>
420+
<Children />
421+
</Popover>,
422+
);
423+
424+
expect(popover).toContainReactComponent(Pane, {
425+
captureOverscroll: false,
426+
});
427+
});
428+
});
429+
});
371430
});
372431

373432
function noop() {}

0 commit comments

Comments
 (0)