test: add test cases for Space.Compact context (#38929)

This commit is contained in:
Yuki Zhang 2022-11-24 20:13:16 +08:00 committed by GitHub
parent 8d2d18c7f3
commit a7ee3364eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,9 @@ import DatePicker from '../../date-picker';
import Select from '../../select';
import TimePicker from '../../time-picker';
import TreeSelect from '../../tree-select';
import Modal from '../../modal';
import Dropdown from '../../dropdown';
import Drawer from '../../drawer';
describe('Space.Compact', () => {
mountTest(Space.Compact);
@ -182,4 +185,66 @@ describe('Space.Compact', () => {
?.classList.contains('ant-btn-compact-vertical-last-item'),
).toBe(true);
});
it('context for Modal', () => {
render(
<Space.Compact size="small">
<Modal title="Basic Modal" open>
<Button>normal button A</Button>
<Input />
</Modal>
</Space.Compact>,
);
expect(
document.body
.querySelectorAll('.ant-modal')[0]
.querySelector('.ant-btn')
?.classList.contains('ant-btn-compact-item'),
).toBe(false);
expect(
document.body
.querySelectorAll('.ant-modal')[0]
.querySelector('.ant-input')
?.classList.contains('ant-input-compact-item'),
).toBe(false);
});
it('context for Dropdown', () => {
render(
<Space.Compact size="small">
<Dropdown.Button
open
menu={{
items: [
{
key: '1',
label: <Button>menu button</Button>,
},
],
}}
>
debug Dropdown.Button context
</Dropdown.Button>
</Space.Compact>,
);
expect(
document.body
.querySelector('.ant-dropdown')
?.querySelector('.ant-btn')
?.classList.contains('ant-btn-compact-item'),
).toBe(false);
});
it('context for Drawer', () => {
render(
<Space.Compact size="small">
<Drawer title="Basic Drawer" open>
<Button>normal button A</Button>
</Drawer>
</Space.Compact>,
);
expect(
document.body
.querySelector('.ant-drawer')
?.querySelector('.ant-btn')
?.classList.contains('ant-btn-compact-item'),
).toBe(false);
});
});