Skip to content

Commit 85fc2aa

Browse files
mumiaoZaoei
andauthored
Refactor/modal with form (#317)
* refactor: modalWithForm component * test: install react-test-renderer * test: perfect single test * docs: improve modalWithForm documentation * feat(modal.form): parameter filtering optimization * feat(modal.form): modify filterPropsByAntdProps to filterAttrByArrays * feat(modal.form): modify demos reference mode * docs(Modal.Form): modifying Document Informationd * refactor: modal.form component logic * refactor: modalWithForm component * test: install react-test-renderer * test: perfect single test * docs: improve modalWithForm documentation * feat(modal.form): parameter filtering optimization * feat(modal.form): modify filterPropsByAntdProps to filterAttrByArrays * feat(modal.form): modify demos reference mode * docs(Modal.Form): modifying Document Informationd * refactor: modal.form component logic --------- Co-authored-by: zaoei <[email protected]>
1 parent 39a96b9 commit 85fc2aa

File tree

14 files changed

+455
-272
lines changed

14 files changed

+455
-272
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"prettier-plugin-packagejson": "^2.2.18",
9696
"react": "^18.0.0",
9797
"react-dom": "^18.0.0",
98+
"react-test-renderer": "^18.2.0",
9899
"stylelint": "^14.9.1",
99100
"ts-jest": "^29.0.3",
100101
"typescript": "~4.5.2"

pnpm-lock.yaml

Lines changed: 71 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export { default as GlobalLoading } from './globalLoading';
1212
export { default as KeyEventListener } from './keyEventListener';
1313
export { default as LoadError } from './errorBoundary/loadError';
1414
export { default as MarkdownRender } from './markdownRender';
15-
export { default as ModalWithForm } from './modalWithForm';
15+
export { default as Modal } from './modal';
1616
export { default as MultiSearchInput } from './multiSearchInput';
1717
export { default as MxGraphContainer, WIDGETS_PREFIX } from './mxGraph';
1818
export { default as NotFound } from './notFound';

src/modalWithForm/__tests__/modalWithForm.test.tsx renamed to src/modal/__tests__/modalWithForm.test.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React from 'react';
2-
import ModalWithForm, { useFilterFormProps } from '../index';
2+
import Modal from '../';
33
import { Input, Form } from 'antd';
44
import { render, fireEvent, screen, cleanup } from '@testing-library/react';
5-
import { renderHook } from '@testing-library/react-hooks';
65
import '@testing-library/jest-dom/extend-expect';
76

87
const FormItem = Form.Item;
9-
const EnhancedModal = ModalWithForm((_props: any) => {
8+
const EnhancedModal = Modal.Form((_props: any) => {
109
return (
1110
<FormItem label="test-label" name="test" rules={[{ max: 10 }]}>
1211
<Input data-testid="test-input" />
@@ -84,16 +83,3 @@ test('should trigger submit methond when form validate successful', () => {
8483
fireEvent.click(eleOk);
8584
expect(eleOk.onclick).toHaveBeenCalled();
8685
});
87-
88-
test('test useFilterFormProps', () => {
89-
const { result } = renderHook(() =>
90-
useFilterFormProps({
91-
a: 1,
92-
onOk: () => {},
93-
disabled: false,
94-
})
95-
);
96-
expect(result.current).toEqual({
97-
disabled: false,
98-
});
99-
});

0 commit comments

Comments
 (0)