diff --git a/packages/design/src/modal/Modal.tsx b/packages/design/src/modal/Modal.tsx index 5accf24a0..df651a5bf 100644 --- a/packages/design/src/modal/Modal.tsx +++ b/packages/design/src/modal/Modal.tsx @@ -6,7 +6,7 @@ import ConfigProvider from '../config-provider'; import { modal } from '../static-function'; import useStyle from './style'; -const Modal = ({ prefixCls: customizePrefixCls, className, ...restProps }: ModalProps) => { +const Modal = ({ footer, prefixCls: customizePrefixCls, className, ...restProps }: ModalProps) => { const { getPrefixCls } = useContext(ConfigProvider.ConfigContext); const prefixCls = getPrefixCls('modal', customizePrefixCls); const { wrapSSR } = useStyle(prefixCls); @@ -15,6 +15,9 @@ const Modal = ({ prefixCls: customizePrefixCls, className, ...restProps }: Modal return wrapSSR( should hide footer dom when footer is false 1`] = ` +
+
+
+
+
+ +
+`; + +exports[`Modal > should hide footer dom when footer is null 1`] = ` +
+
+
+
+
+ +
+`; diff --git a/packages/design/src/modal/__tests__/modal.test.tsx b/packages/design/src/modal/__tests__/modal.test.tsx new file mode 100644 index 000000000..8e730d49f --- /dev/null +++ b/packages/design/src/modal/__tests__/modal.test.tsx @@ -0,0 +1,38 @@ +import React, { useEffect } from 'react'; +import { render } from '@testing-library/react'; +import { Modal } from '@oceanbase/design'; +import type { ModalProgressProps } from '@oceanbase/design/es/modal'; + +const ModalTest: React.FC = props => { + const [open, setOpen] = React.useState(false); + const container = React.useRef(null); + useEffect(() => { + setOpen(true); + }, []); + return ( +
+
+ +
+ ); +}; + +describe('Modal', () => { + it('should hide footer dom when footer is null', () => { + const { container, asFragment } = render(); + expect(container.querySelector('.ant-modal-footer')).toBeFalsy(); + expect(asFragment().firstChild).toMatchSnapshot(); + }); + + it('should hide footer dom when footer is false', () => { + const { container, asFragment } = render(); + expect(container.querySelector('.ant-modal-footer')).toBeFalsy(); + expect(asFragment().firstChild).toMatchSnapshot(); + }); +});