feat(blocksAntd): Modal and tests

This commit is contained in:
Gervwyk 2020-11-19 21:59:49 +02:00 committed by Sam Tolmay
parent 951c04ffa5
commit c891d70676
5 changed files with 2250 additions and 86 deletions

View File

@ -4,91 +4,54 @@
type: Modal
properties:
title: Modal title
- id: areas.content
type: Modal
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: centered: true"
type: Modal
properties:
centered: true
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: closable: false"
type: Modal
properties:
closable: false
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: footer: false"
type: Modal
properties:
footer: false
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: mask: false"
type: Modal
properties:
mask: false
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: maskClosable: false"
type: Modal
properties:
maskClosable: false
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: okText: Text of the OK button"
type: Modal
properties:
okText: Text of the OK button
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: cancelText: Text of the Cancel button "
- id: "properties: cancelText: Text of the Cancel button"
type: Modal
properties:
cancelText: Text of the Cancel button
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: width: 550px - 520px is default"
- id: "properties: width: 350px - 520px is default"
type: Modal
properties:
width: 550px
areas:
content:
blocks:
- id: testArea
type: Test
width: 350
- id: "properties: zIndex: 1200 - 1000 is the default"
type: Modal
properties:
zIndex: 1200
areas:
content:
blocks:
- id: testArea
type: Test
- id: "properties: bodyStyle: border: 10px solid blue"
type: Modal
properties:
bodyStyle:
border: 10px solid blue
- id: "properties: maskStyle: border: 10px solid blue"
type: Modal
properties:
maskStyle:
border: 10px solid blue
- id: "properties: wrapperStyle: border: 10px solid blue"
type: Modal
properties:
wrapperStyle:
border: 10px solid blue

View File

@ -34,7 +34,6 @@ const ModalBlock = ({ blockId, content, properties, actions, methods }) => {
}
return (
<div id={blockId}>
<div id={`${blockId}_popup`} />
<Modal
id={`${blockId}_modal`}
title={properties.title}
@ -50,7 +49,6 @@ const ModalBlock = ({ blockId, content, properties, actions, methods }) => {
setOpen(false);
}}
afterClose={() => methods.callAction({ action: 'afterClose' })}
getContainer={() => document.getElementById(`${blockId}_popup`)}
confirmLoading={get(actions, 'onOk.loading')}
okText={properties.okText || 'Ok'}
cancelText={properties.cancelText || 'Cancel'}

View File

@ -1,6 +1,20 @@
{
"category": "container",
"loading": false,
"test": {
"methods": [
{
"name": "toggleOpen",
"args": {}
},
{
"name": "setOpen",
"args": {
"open": true
}
}
]
},
"schema": {
"properties": {
"type": "object",

View File

@ -14,11 +14,26 @@
limitations under the License.
*/
import { runBlockSchemaTests, runRenderTests } from '@lowdefy/block-tools';
import { runBlockSchemaTests, runMethodTests } from '@lowdefy/block-tools';
import Enzyme, { mount } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import { Modal } from 'antd';
import Modal from '../src/blocks/Modal/Modal';
Enzyme.configure({ adapter: new Adapter() });
import ModalBlock from '../src/blocks/Modal/Modal';
import examples from '../demo/examples/Modal.yaml';
import meta from '../src/blocks/Modal/Modal.json';
runRenderTests({ examples, Block: Modal, meta });
jest.mock('antd/lib/modal', () => {
return jest.fn((props) => props.toString());
});
const mocks = [
{
name: 'default',
fn: Modal,
},
];
runMethodTests({ examples, Block: ModalBlock, mocks, meta, enzyme: { mount } });
runBlockSchemaTests({ examples, meta });

File diff suppressed because it is too large Load Diff