test(transfer): add test case

This commit is contained in:
yiran 2024-11-22 13:40:32 +08:00
parent 71a796831c
commit 1512ddd1b2
2 changed files with 28 additions and 0 deletions

View File

@ -663,6 +663,17 @@ describe('Transfer', () => {
expect(getByText('1 of 2')).toBeTruthy();
});
it('should disable transfer operation button when some items are set to selected but also disabled', () => {
const dataSource = listDisabledProps.dataSource.map((d) => ({
...d,
disabled: true,
}));
const { container } = render(<Transfer {...listDisabledProps} dataSource={dataSource} />);
expect(
container.querySelectorAll<HTMLDivElement>('.ant-transfer-operation button').item(0),
).toBeDisabled();
});
describe('pagination', () => {
it('boolean', async () => {
const { getByTitle } = render(<Transfer {...listDisabledProps} pagination />);

View File

@ -66,6 +66,23 @@ describe('Transfer.List', () => {
);
});
it('should disabled all select checkbox when each item of dataSource is disabled', () => {
const allDisabledListProps: TransferListProps<KeyWiseTransferItem> = {
...listCommonProps,
dataSource: listCommonProps.dataSource.map((d) => ({
...d,
disabled: true,
})),
};
const { container } = render(<List {...allDisabledListProps} />);
expect(container.querySelector<HTMLLabelElement>('label.ant-checkbox-wrapper')).toHaveClass(
'ant-checkbox-wrapper-disabled',
);
expect(container.querySelector<HTMLSpanElement>('span.ant-checkbox')).toHaveClass(
'ant-checkbox-disabled',
);
});
it('support custom dropdown Icon', () => {
const { container } = render(
<List