feat(blocksAntd): Notification and method tests

This commit is contained in:
Gervwyk 2020-11-19 17:19:28 +02:00
parent bf545f9cdb
commit 4d91e05230
3 changed files with 35 additions and 569 deletions

View File

@ -13,12 +13,6 @@
"status": "warning"
}
},
{
"name": "open",
"args": {
"status": "error"
}
},
{
"name": "open",
"args": {

View File

@ -14,24 +14,48 @@
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 { message } from 'antd';
Enzyme.configure({ adapter: new Adapter() });
import Message from '../src/blocks/Message/Message';
import examples from '../demo/examples/Message.yaml';
import meta from '../src/blocks/Message/Message.json';
const reset = () => {
document.body.childNodes.forEach((node) => {
node.childNodes.forEach((childNode) => {
childNode.childNodes.forEach((childChildNode) => {
childChildNode.innerHTML = '';
});
});
});
};
jest.mock('antd/lib/message', () => {
return {
error: jest.fn(),
info: jest.fn(),
loading: jest.fn(),
success: jest.fn(),
warning: jest.fn(),
};
});
runRenderTests({ examples, Block: Message, meta, reset, enzyme: { mount } });
const mocks = [
{
name: 'error',
fn: message.error,
},
{
name: 'info',
fn: message.info,
},
{
name: 'loading',
fn: message.loading,
},
{
name: 'success',
fn: message.success,
},
{
name: 'warning',
fn: message.warning,
},
];
runMethodTests({ examples, Block: Message, meta, mocks, enzyme: { mount } });
runBlockSchemaTests({ examples, meta });

View File

@ -1656,558 +1656,6 @@ Array [
exports[`Render for method: {"name":"open","args":{"message":"Args message"}} - properties.top: 250 placement: topLeft - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - default - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "default_notification",
"message": "default",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - default - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - default - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - default - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.bottom: 250 placement: bottomLeft - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": 250,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.bottom: 250 placement: bottomLeft_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": "bottomLeft",
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.bottom: 250 placement: bottomLeft - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.bottom: 250 placement: bottomLeft - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.bottom: 250 placement: bottomLeft - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.button: icon - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": <ButtonBlock
actions={Object {}}
blockId="properties.button: icon_button"
content={Object {}}
list={Array []}
menus={Array []}
methods={
Object {
"callAction": [MockFunction],
"makeCssClass": [MockFunction] {
"calls": Array [
Array [
undefined,
],
],
"results": Array [
Object {
"type": "return",
"value": "{}",
},
],
},
"moveItemDown": [MockFunction],
"moveItemUp": [MockFunction],
"pushItem": [MockFunction],
"registerAction": [MockFunction],
"registerMethod": [Function],
"removeItem": [MockFunction],
"setValue": [MockFunction],
"unshiftItem": [MockFunction],
}
}
onClick={[Function]}
properties={
Object {
"icon": "SaveOutlined",
"title": "Close",
}
}
required={false}
user={Object {}}
validation={
Object {
"errors": Array [],
"status": null,
"warnings": Array [],
}
}
/>,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.button: icon_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.button: icon - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.button: icon - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.button: icon - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.closeIcon: AlertOutlined - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": <IconBlock
actions={Object {}}
blockId="properties.closeIcon: AlertOutlined_closeIcon"
content={Object {}}
list={Array []}
menus={Array []}
methods={
Object {
"callAction": [MockFunction],
"makeCssClass": [MockFunction] {
"calls": Array [
Array [
undefined,
],
],
"results": Array [
Object {
"type": "return",
"value": "{}",
},
],
},
"moveItemDown": [MockFunction],
"moveItemUp": [MockFunction],
"pushItem": [MockFunction],
"registerAction": [MockFunction],
"registerMethod": [Function],
"removeItem": [MockFunction],
"setValue": [MockFunction],
"unshiftItem": [MockFunction],
}
}
properties="AlertOutlined"
required={false}
user={Object {}}
validation={
Object {
"errors": Array [],
"status": null,
"warnings": Array [],
}
}
/>,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.closeIcon: AlertOutlined_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.closeIcon: AlertOutlined - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.closeIcon: AlertOutlined - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.closeIcon: AlertOutlined - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.description: - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": "Notification status type.",
"duration": undefined,
"icon": undefined,
"id": "properties.description:_notification",
"message": "properties.description:",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.description: - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.description: - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.description: - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.duration: 6 - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": 6,
"icon": undefined,
"id": "properties.duration: 6_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.duration: 6 - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.duration: 6 - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.duration: 6 - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.icon - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": <IconBlock
actions={Object {}}
blockId="undefined_id"
content={Object {}}
list={Array []}
menus={Array []}
methods={
Object {
"callAction": [MockFunction],
"makeCssClass": [MockFunction] {
"calls": Array [
Array [
undefined,
],
],
"results": Array [
Object {
"type": "return",
"value": "{}",
},
],
},
"moveItemDown": [MockFunction],
"moveItemUp": [MockFunction],
"pushItem": [MockFunction],
"registerAction": [MockFunction],
"registerMethod": [Function],
"removeItem": [MockFunction],
"setValue": [MockFunction],
"unshiftItem": [MockFunction],
}
}
properties="AccountBookFilled"
required={false}
user={Object {}}
validation={
Object {
"errors": Array [],
"status": null,
"warnings": Array [],
}
}
/>,
"id": "properties.icon_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.icon - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.icon - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.icon - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.message - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.message_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.message - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.message - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.message - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomLeft - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.placement: bottomLeft_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": "bottomLeft",
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomLeft - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomLeft - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomLeft - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomRight - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.placement: bottomRight_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": "bottomRight",
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomRight - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomRight - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: bottomRight - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: topLeft - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.placement: topLeft_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": "topLeft",
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: topLeft - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: topLeft - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.placement: topLeft - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: error - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.status: error_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: error - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: error - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: error - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: info - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.status: info_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: info - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: info - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: info - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: warning - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": "Notification status type.",
"duration": undefined,
"icon": undefined,
"id": "properties.status: warning_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": undefined,
"top": undefined,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: warning - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: warning - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.status: warning - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.top: 250 placement: topLeft - value[0] - error 1`] = `
Array [
Array [
Object {
"bottom": undefined,
"btn": undefined,
"className": "{}",
"closeIcon": undefined,
"description": undefined,
"duration": undefined,
"icon": undefined,
"id": "properties.top: 250 placement: topLeft_notification",
"message": "Notification message",
"onClick": [Function],
"onClose": [Function],
"placement": "topLeft",
"top": 250,
},
],
]
`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.top: 250 placement: topLeft - value[0] - info 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.top: 250 placement: topLeft - value[0] - success 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"error"}} - properties.top: 250 placement: topLeft - value[0] - warning 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"warning"}} - default - value[0] - error 1`] = `Array []`;
exports[`Render for method: {"name":"open","args":{"status":"warning"}} - default - value[0] - info 1`] = `Array []`;