test: add unit test

This commit is contained in:
wuxh
2023-06-16 16:48:53 +08:00
parent f0059cebc2
commit 7559a15af6

View File

@@ -5,6 +5,7 @@ import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { fireEvent, render } from '../../../tests/utils';
import { resetWarned } from '../../_util/warning';
import Form, { FormProps } from '../../form';
jest.mock('rc-util/lib/Portal');
@@ -126,4 +127,27 @@ describe('Modal', () => {
render(<Modal open footer={<div className="custom-footer">footer</div>} />);
expect(document.querySelector('.custom-footer')).toBeTruthy();
});
describe('in Form', () => {
const FormDemo = (opt: { formProps?: FormProps; modalProps?: ModalProps }) => (
<Form {...(opt.formProps ?? {})}>
<Form.Item label="label">
<Modal {...(opt.modalProps ?? {})} />
</Form.Item>
</Form>
);
it('should not pass disabled to footer', () => {
const { getAllByRole } = render(
<FormDemo formProps={{ disabled: true }} modalProps={{ open: true }} />,
);
const footerBts = getAllByRole('button');
expect(footerBts).toBeTruthy();
footerBts.forEach((bt) => {
expect(bt).not.toHaveAttribute('disabled');
});
});
});
});