vendor: amis 6.13.0 base (fork root)

This commit is contained in:
2026-06-16 22:14:57 +08:00
commit 8c8e4247a9
3840 changed files with 2467374 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EventAction:ajax 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
发送请求
</span>
</button>
<span
class="cxd-TplField fr-view"
>
<span>
18岁的天空
</span>
</span>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
发送请求2
</span>
</button>
<span
class="cxd-TplField fr-view"
>
<span>
18岁的天空,status:0,msg:ok
</span>
</span>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:ajax args 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
发送请求
</span>
</button>
<span
class="cxd-TplField fr-view"
>
<span>
18岁的天空
</span>
</span>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
发送请求2
</span>
</button>
<span
class="cxd-TplField fr-view"
>
<span>
18岁的天空,status:0,msg:ok
</span>
</span>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:ajax sendOn 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
发送请求
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,160 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EventAction:custom 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作1
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作2
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作3
</span>
</button>
<span
class="cxd-TplField fr-view"
>
<span>
18岁的天空
</span>
</span>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:custom 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作1
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作2
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作3
</span>
</button>
<span
class="cxd-TplField fr-view"
>
<span>
18岁的天空
</span>
</span>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:custom 3`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作1
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作2
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
自定义动作3
</span>
</button>
<span
class="cxd-TplField fr-view"
>
<span>
17岁的天空
</span>
</span>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,597 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`1. EventAction:dialog args 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
<div
class="amis-dialog-widget cxd-Modal cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Modal-overlay in"
/>
<div
class="cxd-Modal-content in"
>
<div
class="cxd-Modal-header"
>
<a
class="cxd-Modal-close"
data-position="left"
data-tooltip="关闭"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Modal-title"
>
模态弹窗
</div>
</div>
<div
class="cxd-Modal-body"
role="dialog-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开子弹窗
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default ml-2"
type="button"
>
<span>
关闭当前弹窗
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default ml-2"
type="button"
>
<span>
触发确认
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default ml-2"
type="button"
>
<span>
触发取消
</span>
</button>
</div>
<div
class="cxd-Modal-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`1. EventAction:dialog args 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`1. EventAction:dialog args 3`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`1. EventAction:dialog args 4`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`1. EventAction:dialog args 5`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`1. EventAction:dialog args 6`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`1. EventAction:dialog args 7`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`2. EventAction:dialog 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
<div
class="amis-dialog-widget cxd-Modal cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Modal-overlay in"
/>
<div
class="cxd-Modal-content in"
>
<div
class="cxd-Modal-header"
>
<a
class="cxd-Modal-close"
data-position="left"
data-tooltip="关闭"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Modal-title"
>
模态弹窗
</div>
</div>
<div
class="cxd-Modal-body"
role="dialog-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开子弹窗
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default ml-2"
type="button"
>
<span>
关闭当前弹窗
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default ml-2"
type="button"
>
<span>
触发确认
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default ml-2"
type="button"
>
<span>
触发取消
</span>
</button>
</div>
<div
class="cxd-Modal-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`2. EventAction:dialog 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`2. EventAction:dialog 3`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`2. EventAction:dialog 4`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`2. EventAction:dialog 5`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`2. EventAction:dialog 6`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`2. EventAction:dialog 7`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,112 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EventAction:disabled 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Button cxd-Button--default cxd-Button--size-default is-disabled"
disabled=""
>
<span>
按钮1
</span>
</div>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
按钮2
</span>
</button>
<div
class="cxd-Button cxd-Button--default cxd-Button--size-default is-disabled"
disabled=""
>
<span>
按钮3
</span>
</div>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
按钮4
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
按钮5
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
按钮6
</span>
</button>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Button cxd-Button--default cxd-Button--size-default is-disabled ml-2"
disabled=""
>
<span>
我的状态变了
</span>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,561 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EventAction:drawer 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
<div
class="amis-dialog-widget cxd-Drawer cxd-Drawer--right cxd-Drawer--md cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Drawer-overlay in"
/>
<div
class="cxd-Drawer-content in"
>
<a
class="cxd-Drawer-close"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Drawer-header"
>
<div
class="cxd-Drawer-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
模态抽屉
</span>
</span>
</div>
</div>
<div
class="cxd-Drawer-body"
>
<div
class="cxd-Spinner-overlay in"
/>
<div
class="cxd-Spinner cxd-Spinner--overlay in"
data-testid="spinner"
>
<div
class="cxd-Spinner-icon cxd-Spinner-icon--lg cxd-Spinner-icon--default"
/>
</div>
</div>
<div
class="cxd-Drawer-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer 3`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer 4`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer 5`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer 6`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer 7`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer args 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
<div
class="amis-dialog-widget cxd-Drawer cxd-Drawer--right cxd-Drawer--md cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Drawer-overlay in"
/>
<div
class="cxd-Drawer-content in"
>
<a
class="cxd-Drawer-close"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Drawer-header"
>
<div
class="cxd-Drawer-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
模态抽屉
</span>
</span>
</div>
</div>
<div
class="cxd-Drawer-body"
>
<div
class="cxd-Spinner-overlay in"
/>
<div
class="cxd-Spinner cxd-Spinner--overlay in"
data-testid="spinner"
>
<div
class="cxd-Spinner-icon cxd-Spinner-icon--lg cxd-Spinner-icon--default"
/>
</div>
</div>
<div
class="cxd-Drawer-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer args 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer args 3`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer args 4`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer args 5`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer args 6`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;
exports[`EventAction:drawer args 7`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
打开抽屉
</span>
</button>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,106 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EventAction:prevent 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default ml-2"
type="button"
>
<span>
打开弹窗
</span>
</button>
</div>
</div>
</div>
</div>
<div
class="amis-dialog-widget cxd-Modal cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Modal-overlay in"
/>
<div
class="cxd-Modal-content in"
>
<div
class="cxd-Modal-header"
>
<a
class="cxd-Modal-close"
data-position="left"
data-tooltip="关闭"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Modal-title"
>
提示
</div>
</div>
<div
class="cxd-Modal-body"
role="dialog-body"
>
<div
class="cxd-Alert cxd-Alert--warning"
>
<div
class="cxd-Alert-content"
>
<div
class="cxd-Alert-desc"
>
<span
class="cxd-TplField fr-view"
>
<span>
确认后将不关闭弹窗
</span>
</span>
</div>
</div>
</div>
</div>
<div
class="cxd-Modal-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,819 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('EventAction:ajax args', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
age: 18
}
}
})
);
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
id: 'page_001',
data: {
name: 'lll'
},
body: [
{
type: 'button',
label: '发送请求',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
args: {
api: {
url: '/api/xxx',
method: 'get'
},
messages: {
success: '成功了!欧耶',
failed: '失败了呢。。'
}
},
outputVar: 'result'
},
{
actionType: 'setValue',
componentId: 'page_001',
args: {
value: '${event.data.result.responseData}'
}
}
]
}
}
},
{
type: 'tpl',
tpl: '${age}岁的天空'
},
{
type: 'button',
label: '发送请求2',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
args: {
api: {
url: '/api/xxx',
method: 'get'
},
messages: {
success: '成功了!欧耶',
failed: '失败了呢。。'
}
}
},
{
actionType: 'setValue',
componentId: 'page_001',
args: {
value: '${event.data}'
}
}
]
}
}
},
{
type: 'tpl',
tpl: '${responseResult.responseData.age}岁的天空,status:${responseResult.responseStatus},msg:${responseResult.responseMsg}'
}
]
},
{},
makeEnv({
fetcher
})
)
);
fireEvent.click(getByText('发送请求'));
await waitFor(() => {
expect(getByText('18岁的天空')).toBeInTheDocument();
});
fireEvent.click(getByText('发送请求2'));
await waitFor(() => {
expect(getByText('18岁的天空,status:0,msg:ok')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('EventAction:ajax', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
age: 18
}
}
})
);
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
id: 'page_001',
data: {
name: 'lll'
},
body: [
{
type: 'button',
label: '发送请求',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx',
method: 'get'
},
messages: {
success: '成功了!欧耶',
failed: '失败了呢。。'
},
outputVar: 'result'
},
{
actionType: 'setValue',
componentId: 'page_001',
args: {
value: '${event.data.result.responseData}'
}
}
]
}
}
},
{
type: 'tpl',
tpl: '${age}岁的天空'
},
{
type: 'button',
label: '发送请求2',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx',
method: 'get'
},
messages: {
success: '成功了!欧耶',
failed: '失败了呢。。'
}
},
{
actionType: 'setValue',
componentId: 'page_001',
args: {
value: '${event.data}'
}
}
]
}
}
},
{
type: 'tpl',
tpl: '${responseResult.responseData.age}岁的天空,status:${responseResult.responseStatus},msg:${responseResult.responseMsg}'
}
]
},
{},
makeEnv({
fetcher
})
)
);
fireEvent.click(getByText('发送请求'));
await waitFor(() => {
expect(getByText('18岁的天空')).toBeInTheDocument();
});
fireEvent.click(getByText('发送请求2'));
await waitFor(() => {
expect(getByText('18岁的天空,status:0,msg:ok')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('EventAction:ajax data1', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'amis',
age: 18
}
}
})
);
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
name: 'lll'
},
body: [
{
type: 'button',
label: '发送请求',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
args: {
api: {
url: '/api/xxx?name=${event.data.name}',
method: 'post',
data: {
myname1: '${name}',
myname2: '\\${name}',
myname3: '${text}',
myname4: '\\${text}'
}
}
},
outputVar: 'result'
},
{
actionType: 'ajax',
args: {
api: {
url: '/api/xxx?q1=${result.responseData.age}',
method: 'post',
data: {
param1: '${event.data.result.responseData.name}',
param2: '${responseData.name}',
param3: '${result.name}',
param4: '${event.data.responseData.name}'
}
}
}
},
{
actionType: 'ajax',
args: {
api: {
url: '/api/xxx?name=${event.data.name}',
method: 'post',
data: {
myname1: '${name}',
myname2: '\\${name}',
myname3: '${text}',
myname4: '\\${text}'
}
},
other: '${name}'
}
}
]
}
}
}
]
},
{
data: {
text: '${lll}'
}
},
makeEnv({
fetcher
})
)
);
await waitFor(() => {
expect(getByText('发送请求')).toBeInTheDocument();
});
fireEvent.click(getByText(/发送请求/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(3);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/xxx?name=lll');
expect(fetcher.mock.calls[0][0].data).toMatchObject({
myname1: 'lll',
myname2: '${name}',
myname3: '${lll}',
myname4: '${text}'
});
expect(fetcher.mock.calls[1][0].url).toEqual('/api/xxx?q1=18');
expect(fetcher.mock.calls[1][0].data).toMatchObject({
param1: 'amis',
param2: 'amis',
param3: 'amis',
param4: 'amis'
});
// 测试干扰配置
expect(fetcher.mock.calls[0][0].url).toEqual('/api/xxx?name=lll');
expect(fetcher.mock.calls[0][0].data).toMatchObject({
myname1: 'lll',
myname2: '${name}',
myname3: '${lll}',
myname4: '${text}'
});
});
});
test('EventAction:ajax data2', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'amis',
age: 18
}
}
})
);
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
name: 'lll'
},
body: [
{
type: 'button',
label: '发送请求',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx?name=${event.data.name}',
method: 'post',
data: {
myname1: '${name}',
myname2: '\\${name}',
myname3: '${text}',
myname4: '\\${text}'
}
},
outputVar: 'result'
},
{
actionType: 'ajax',
api: {
url: '/api/xxx?q1=${result.responseData.age}',
method: 'post',
data: {
param1: '${event.data.result.responseData.name}',
param2: '${responseData.name}',
param3: '${result.name}',
param4: '${event.data.responseData.name}'
}
}
}
]
}
}
}
]
},
{
data: {
text: '${lll}'
}
},
makeEnv({
fetcher
})
)
);
await waitFor(() => {
expect(getByText('发送请求')).toBeInTheDocument();
});
fireEvent.click(getByText(/发送请求/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/xxx?name=lll');
expect(fetcher.mock.calls[0][0].data).toMatchObject({
myname1: 'lll',
myname2: '${name}',
myname3: '${lll}',
myname4: '${text}'
});
expect(fetcher.mock.calls[1][0].url).toEqual('/api/xxx?q1=18');
expect(fetcher.mock.calls[1][0].data).toMatchObject({
param1: 'amis',
param2: 'amis',
param3: 'amis',
param4: 'amis'
});
});
});
test('EventAction:ajax data3', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'amis',
age: 18
}
}
})
);
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '表单外的校验按钮',
className: 'mb-2',
level: 'primary',
onEvent: {
click: {
actions: [
{
componentId: 'form_validate',
outputVar: 'validateResult',
actionType: 'validate'
},
{
outputVar: 'responseResult',
actionType: 'ajax',
api: {
method: 'post',
url: '/api/xxx1',
data: {
name: '${name}',
email: '${email}'
}
}
}
]
}
}
},
{
type: 'form',
id: 'form_validate',
data: {
name: 'amis',
email: 'amis@baidu.com'
},
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:',
required: true
},
{
name: 'email',
type: 'input-text',
label: '邮箱:',
required: true,
validations: {
isEmail: true
}
}
],
actions: [
{
type: 'button',
label: '表单内的校验按钮',
level: 'primary',
onEvent: {
click: {
actions: [
{
componentId: 'form_validate',
outputVar: 'validateResult',
actionType: 'validate'
},
{
outputVar: 'responseResult',
actionType: 'ajax',
api: {
method: 'post',
url: '/api/xxx2',
data: {
name: '${name}',
email: '${email}'
}
}
}
]
}
}
},
{
type: 'button',
label: '无data',
level: 'primary',
onEvent: {
click: {
actions: [
{
componentId: 'form_validate',
outputVar: 'validateResult',
actionType: 'validate'
},
{
outputVar: 'responseResult',
actionType: 'ajax',
api: {
method: 'post',
url: '/api/xxx3'
}
}
]
}
}
},
{
type: 'button',
label: '字符串api无参数',
level: 'primary',
onEvent: {
click: {
actions: [
{
componentId: 'form_validate',
outputVar: 'validateResult',
actionType: 'validate'
},
{
outputVar: 'responseResult',
actionType: 'ajax',
api: 'post:/api/xxx4'
}
]
}
}
}
]
}
]
},
{},
makeEnv({
fetcher
})
)
);
await waitFor(() => {
expect(getByText('表单外的校验按钮')).toBeInTheDocument();
expect(getByText('表单内的校验按钮')).toBeInTheDocument();
expect(getByText('无data')).toBeInTheDocument();
expect(getByText('字符串api无参数')).toBeInTheDocument();
});
fireEvent.click(getByText(/表单外的校验按钮/));
await wait(200);
fireEvent.click(getByText(/表单内的校验按钮/));
await wait(200);
fireEvent.click(getByText(/无data/));
await wait(200);
fireEvent.click(getByText(/字符串api无参数/));
await wait(200);
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(4);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/xxx1');
expect(fetcher.mock.calls[0][0].data).toMatchObject({
name: '',
email: ''
});
expect(fetcher.mock.calls[1][0].url).toEqual('/api/xxx2');
expect(fetcher.mock.calls[1][0].data).toMatchObject({
name: 'amis',
email: 'amis@baidu.com'
});
expect(fetcher.mock.calls[2][0].url).toEqual('/api/xxx3');
expect(fetcher.mock.calls[2][0].data).toMatchObject({});
expect(fetcher.mock.calls[3][0].url).toEqual('/api/xxx4');
expect(fetcher.mock.calls[3][0].data).toMatchObject({});
});
});
test('EventAction:ajax silent', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() => {
return Promise.resolve({
data: {
status: 0,
msg: 'ok'
}
});
});
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '发送请求1',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx1',
method: 'post',
silent: true
}
}
]
}
}
},
{
type: 'button',
label: '发送请求2',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx2',
method: 'post',
silent: false
}
}
]
}
}
},
{
type: 'button',
label: '发送请求3',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx3',
method: 'post'
},
options: {
silent: true
}
}
]
}
}
},
{
type: 'button',
label: '发送请求4',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx4',
method: 'post'
},
options: {
silent: false
}
}
]
}
}
}
]
},
{},
makeEnv({
fetcher,
notify
})
)
);
await waitFor(() => {
expect(getByText('发送请求1')).toBeInTheDocument();
expect(getByText('发送请求2')).toBeInTheDocument();
expect(getByText('发送请求3')).toBeInTheDocument();
expect(getByText('发送请求4')).toBeInTheDocument();
});
fireEvent.click(getByText(/发送请求1/));
fireEvent.click(getByText(/发送请求2/));
fireEvent.click(getByText(/发送请求3/));
fireEvent.click(getByText(/发送请求4/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(4);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/xxx1');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/xxx2');
expect(fetcher.mock.calls[2][0].url).toEqual('/api/xxx3');
expect(fetcher.mock.calls[3][0].url).toEqual('/api/xxx4');
expect(notify).toBeCalledTimes(2);
});
});
test('EventAction:ajax sendOn', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
age: 18
}
}
})
);
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '发送请求',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: {
url: '/api/xxx',
method: 'get',
sendOn: '${1 !== 1}'
}
}
]
}
}
}
]
},
{},
makeEnv({
fetcher
})
)
);
fireEvent.click(getByText('发送请求'));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(0);
});
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,74 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('EventAction:copy', async () => {
const copy = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
content: 'http://www.baidu.com'
},
body: [
{
type: 'action',
label: '复制',
onEvent: {
click: {
actions: [
{
actionType: 'copy',
args: {
content: 'the content is ${content}'
}
}
]
}
}
},
{
type: 'button',
label: '复制富文本',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'copy',
args: {
format: 'text/html',
content:
'the content is <a href="http://www.baidu.com">link</a> <b>bold</b>'
}
}
]
}
}
}
]
},
{},
makeEnv({
copy
})
)
);
fireEvent.click(getByText('复制'));
await waitFor(() => {
expect(copy).toHaveBeenCalled();
});
expect(copy.mock.calls[0][0]).toEqual('the content is http://www.baidu.com');
fireEvent.click(getByText('复制富文本'));
await waitFor(() => {
expect(copy).toHaveBeenCalled();
});
expect(copy.mock.calls[1][0]).toEqual(
'the content is <a href="http://www.baidu.com">link</a> <b>bold</b>'
);
expect(copy.mock.calls[1][1]).toEqual({format: undefined});
});

View File

@@ -0,0 +1,125 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('EventAction:custom', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
age: 18
}
}
})
);
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
id: 'page_001',
data: {
age: '22'
},
body: [
{
type: 'button',
label: '自定义动作1',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
args: {
script:
"doAction({actionType: 'ajax', api: '/api/xxx', outputVar: 'result'});"
}
},
{
actionType: 'setValue',
componentId: 'page_001',
args: {
value: '${event.data.result.responseData}'
}
}
]
}
}
},
{
type: 'button',
label: '自定义动作2',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
args: {
script:
"doAction({actionType: 'ajax', api: '/api/xxx', outputVar: 'result'});event.stopPropagation();"
}
},
{
actionType: 'setValue',
componentId: 'page_001',
args: {
value: '${event.data.result.responseData}'
}
}
]
}
}
},
{
type: 'button',
label: '自定义动作3',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
args: {
script:
"doAction({actionType: 'setValue', componentId: 'page_001', args: {value: {age: 17}}});"
}
}
]
}
}
},
{
type: 'tpl',
tpl: '${age}岁的天空'
}
]
},
{},
makeEnv({
fetcher
})
)
);
fireEvent.click(getByText('自定义动作1'));
await waitFor(() => {
expect(getByText('18岁的天空')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('自定义动作2'));
await waitFor(() => {
expect(getByText('18岁的天空')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('自定义动作3'));
await waitFor(() => {
expect(getByText('17岁的天空')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,730 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('1. EventAction:dialog args', async () => {
const notify = jest.fn();
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '打开弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
args: {
dialog: {
type: 'dialog',
id: 'dialog_001',
title: '模态弹窗',
body: [
{
type: 'button',
label: '打开子弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
args: {
dialog: {
type: 'dialog',
title: '模态子弹窗',
body: [
{
type: 'button',
label: '关闭父弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'closeDialog',
componentId: 'dialog_001'
}
]
}
}
}
]
}
}
}
]
}
}
},
{
type: 'button',
label: '关闭当前弹窗',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'closeDialog'
}
]
}
}
},
{
type: 'button',
label: '触发确认',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'confirm',
componentId: 'dialog_001'
}
]
}
}
},
{
type: 'button',
label: '触发取消',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'cancel',
componentId: 'dialog_001'
}
]
}
}
}
],
onEvent: {
confirm: {
actions: [
{
actionType: 'toast',
args: {
msg: 'confirm'
}
}
]
},
cancel: {
actions: [
{
actionType: 'toast',
args: {
msg: 'cancel'
}
}
]
}
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container,
notify
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开弹窗'));
expect(container).toMatchSnapshot();
await waitFor(() => {
expect(getByText('确认')).toBeInTheDocument();
});
fireEvent.click(getByText('确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('取消')).toBeInTheDocument();
});
fireEvent.click(getByText('取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
// actions
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('关闭当前弹窗')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭当前弹窗'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('打开子弹窗')).toBeInTheDocument();
});
fireEvent.click(getByText('打开子弹窗'));
await waitFor(() => {
expect(getByText('关闭父弹窗')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭父弹窗'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('触发确认')).toBeInTheDocument();
});
fireEvent.click(getByText('触发确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('触发取消')).toBeInTheDocument();
});
fireEvent.click(getByText('触发取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
}, 7000);
test('2. EventAction:dialog', async () => {
const notify = jest.fn();
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '打开弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
type: 'dialog',
id: 'dialog_001',
title: '模态弹窗',
body: [
{
type: 'button',
label: '打开子弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
type: 'dialog',
title: '模态子弹窗',
body: [
{
type: 'button',
label: '关闭父弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'closeDialog',
componentId: 'dialog_001'
}
]
}
}
}
]
}
}
]
}
}
},
{
type: 'button',
label: '关闭当前弹窗',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'closeDialog'
}
]
}
}
},
{
type: 'button',
label: '触发确认',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'confirm',
componentId: 'dialog_001'
}
]
}
}
},
{
type: 'button',
label: '触发取消',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'cancel',
componentId: 'dialog_001'
}
]
}
}
}
],
onEvent: {
confirm: {
actions: [
{
actionType: 'toast',
args: {
msg: 'confirm'
}
}
]
},
cancel: {
actions: [
{
actionType: 'toast',
args: {
msg: 'cancel'
}
}
]
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container,
notify
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开弹窗'));
expect(container).toMatchSnapshot();
await waitFor(() => {
expect(getByText('确认')).toBeInTheDocument();
});
fireEvent.click(getByText('确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('取消')).toBeInTheDocument();
});
fireEvent.click(getByText('取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
// actions
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('关闭当前弹窗')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭当前弹窗'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('打开子弹窗')).toBeInTheDocument();
});
fireEvent.click(getByText('打开子弹窗'));
await waitFor(() => {
expect(getByText('关闭父弹窗')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭父弹窗'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('触发确认')).toBeInTheDocument();
});
fireEvent.click(getByText('触发确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('触发取消')).toBeInTheDocument();
});
fireEvent.click(getByText('触发取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
}, 7000);
test('3. EventAction:dialog data', async () => {
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
data: {
name: 'amis'
},
body: [
{
type: 'button',
label: '打开弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
args: {
dialog: {
type: 'dialog',
id: 'dialog_001',
title: '模态弹窗${event.data.name}',
body: [
{
type: 'tpl',
tpl: '你好,我是${name}、${name1}、${name2}'
}
],
data: {
name1: '${name}',
name2: '${event.data.name}'
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).toBeInTheDocument();
expect(getByText('模态弹窗')).toBeInTheDocument();
expect(getByText('你好,我是、amis、amis')).toBeInTheDocument(); // 因为事件动作给args提前做了映射
});
}, 7000);
test('4. EventAction:dialog data2', async () => {
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
data: {
name: 'amis'
},
body: [
{
type: 'button',
label: '打开弹窗',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
type: 'dialog',
id: 'dialog_001',
title: '模态弹窗${event.data.name}',
body: [
{
type: 'tpl',
tpl: '你好,我是${name}、${name1}、${name2}'
}
],
data: {
name1: '${name}',
name2: '${event.data.name}'
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).toBeInTheDocument();
expect(getByText('模态弹窗')).toBeInTheDocument();
expect(getByText('你好,我是、amis、amis')).toBeInTheDocument();
});
}, 7000);
// // test('EventAction:alert', async () => {
// // const alert = jest.fn();
// // const {getByText, container}: any = render(
// // amisRender(
// // {
// // type: 'page',
// // data: {
// // msg: '去吃饭了'
// // },
// // body: [
// // {
// // type: 'button',
// // label: '提示对话框',
// // level: 'primary',
// // onEvent: {
// // click: {
// // actions: [
// // {
// // actionType: 'alert',
// // args: {
// // msg: '<a href="http://www.baidu.com" target="_blank">${msg}~</a>'
// // }
// // }
// // ]
// // }
// // }
// // }
// // ]
// // },
// // {},
// // makeEnv({
// // getModalContainer: () => container,
// // alert
// // })
// // )
// // );
// // fireEvent.click(getByText('提示对话框'));
// // await waitFor(() => {
// // expect(alert).toHaveBeenCalled();
// // });
// // expect(alert.mock.calls[0][0]).toEqual(
// // '<a href="http://www.baidu.com" target="_blank">去吃饭了~</a>'
// // );
// // });
// // test('EventAction:confirm', async () => {
// // const confirm = jest.fn();
// // const {getByText, container}: any = render(
// // amisRender(
// // {
// // type: 'page',
// // data: {
// // title: '操作确认',
// // msg: '要删除它吗?'
// // },
// // body: [
// // {
// // type: 'button',
// // label: '确认对话框',
// // level: 'primary',
// // onEvent: {
// // click: {
// // actions: [
// // {
// // actionType: 'confirmDialog',
// // args: {
// // title: '${title}',
// // msg: '<span style="color:red">${msg}</span>'
// // }
// // }
// // ]
// // }
// // }
// // }
// // ]
// // },
// // {},
// // makeEnv({
// // getModalContainer: () => container,
// // confirm
// // })
// // )
// // );
// // fireEvent.click(getByText('确认对话框'));
// // await waitFor(() => {
// // expect(confirm).toHaveBeenCalled();
// // });
// // expect(confirm.mock.calls[0][0]).toEqual(
// // '<span style="color:red">要删除它吗?</span>'
// // );
// // expect(confirm.mock.calls[0][1]).toEqual('操作确认');
// // });
test('5. EventAction:dialog formitem without form', async () => {
const onAction = jest.fn();
let portal: any = null;
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: 'Dialog',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
title: '表单页面',
body: [
{
label: 'A',
type: 'input-text',
name: 'a'
},
{
label: 'B',
type: 'input-text',
name: 'b'
}
],
onEvent: {
confirm: {
actions: [
{
actionType: 'custom',
script: onAction
}
]
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => portal
})
)
);
portal = container;
await wait(200);
const button = getByText('Dialog');
fireEvent.click(button);
await wait(200);
fireEvent.change(container.querySelector('[name="a"]')!, {
target: {value: '1'}
});
await wait(200);
fireEvent.change(container.querySelector('[name="b"]')!, {
target: {value: '2'}
});
await wait(200);
fireEvent.click(getByText('确认'));
await wait(300);
expect(onAction).toHaveBeenCalled();
expect(onAction.mock.calls[0][2].data).toMatchObject({a: '1', b: '2'});
});

View File

@@ -0,0 +1,147 @@
import {fireEvent, render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('EventAction:disabled', async () => {
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
btnDisabled: true,
btnNotDisabled: false
},
body: [
{
type: 'action',
label: '按钮1',
disabledOn: '${btnDisabled}'
},
{
type: 'action',
label: '按钮2',
disabledOn: '${btnNotDisabled}',
onEvent: {
click: {
actions: [
{
actionType: 'disabled',
componentId: 'ui:button_test_3'
}
]
}
}
},
{
type: 'action',
label: '按钮3',
disabledOn: '${btnNotDisabled}',
id: 'ui:button_test_3'
},
{
type: 'action',
label: '按钮4',
disabledOn: '${btnNotDisabled}',
onEvent: {
click: {
actions: [
{
actionType: 'enabled',
componentId: 'ui:button_test_5'
}
]
}
}
},
{
type: 'action',
label: '按钮5',
disabled: true,
id: 'ui:button_test_5'
},
{
type: 'action',
label: '按钮6',
onEvent: {
click: {
actions: [
{
actionType: 'disabled',
componentId: 'ui:form_disable'
}
]
}
}
},
{
type: 'form',
id: 'ui:form_disable',
title: '表单',
body: [
{
type: 'button',
className: 'ml-2',
label: '我的状态变了'
}
]
}
]
},
{},
makeEnv({})
)
);
fireEvent.click(getByText(/按钮2/));
fireEvent.click(getByText(/按钮4/));
fireEvent.click(getByText(/按钮6/));
expect(container).toMatchSnapshot();
});
test('EventAction:disabledFormItem', async () => {
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
body: [
{
type: 'textarea',
id: 'textarea',
name: 'textarea',
disabled: true
}
]
},
{
type: 'action',
label: '启用textarea',
onEvent: {
click: {
actions: [
{
actionType: 'enabled',
componentId: 'textarea'
}
]
}
}
}
]
},
{},
makeEnv({})
)
);
expect(container.querySelector('textarea[name="textarea"]')).toBeDisabled();
fireEvent.click(getByText(/启用textarea/));
await wait(200);
expect(
container.querySelector('textarea[name="textarea"]')
).not.toBeDisabled();
});

View File

@@ -0,0 +1,560 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('EventAction:drawer args', async () => {
const notify = jest.fn();
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '打开抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
args: {
drawer: {
type: 'drawer',
id: 'drawer_001',
title: '模态抽屉',
body: [
{
type: 'button',
label: '打开子抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
args: {
drawer: {
type: 'drawer',
title: '模态子抽屉',
body: [
{
type: 'button',
label: '关闭父抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'closeDrawer',
componentId: 'drawer_001'
}
]
}
}
}
]
}
}
}
]
}
}
},
{
type: 'button',
label: '关闭当前抽屉',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'closeDrawer'
}
]
}
}
},
{
type: 'button',
label: '触发确认',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'confirm',
componentId: 'drawer_001'
}
]
}
}
},
{
type: 'button',
label: '触发取消',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'cancel',
componentId: 'drawer_001'
}
]
}
}
}
],
onEvent: {
confirm: {
actions: [
{
actionType: 'toast',
args: {
msg: 'confirm'
}
}
]
},
cancel: {
actions: [
{
actionType: 'toast',
args: {
msg: 'cancel'
}
}
]
}
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container,
notify
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开抽屉'));
expect(container).toMatchSnapshot();
await waitFor(() => {
expect(getByText('确认')).toBeInTheDocument();
});
fireEvent.click(getByText('确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('取消')).toBeInTheDocument();
});
fireEvent.click(getByText('取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
// actions
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('关闭当前抽屉')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭当前抽屉'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('打开子抽屉')).toBeInTheDocument();
});
fireEvent.click(getByText('打开子抽屉'));
await waitFor(() => {
expect(getByText('关闭父抽屉')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭父抽屉'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('触发确认')).toBeInTheDocument();
});
fireEvent.click(getByText('触发确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('触发取消')).toBeInTheDocument();
});
fireEvent.click(getByText('触发取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
}, 7000);
test('EventAction:drawer', async () => {
const notify = jest.fn();
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '打开抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
drawer: {
type: 'drawer',
id: 'drawer_001',
title: '模态抽屉',
body: [
{
type: 'button',
label: '打开子抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
drawer: {
type: 'drawer',
title: '模态子抽屉',
body: [
{
type: 'button',
label: '关闭父抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'closeDrawer',
componentId: 'drawer_001'
}
]
}
}
}
]
}
}
]
}
}
},
{
type: 'button',
label: '关闭当前抽屉',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'closeDrawer'
}
]
}
}
},
{
type: 'button',
label: '触发确认',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'confirm',
componentId: 'drawer_001'
}
]
}
}
},
{
type: 'button',
label: '触发取消',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'cancel',
componentId: 'drawer_001'
}
]
}
}
}
],
onEvent: {
confirm: {
actions: [
{
actionType: 'toast',
args: {
msg: 'confirm'
}
}
]
},
cancel: {
actions: [
{
actionType: 'toast',
args: {
msg: 'cancel'
}
}
]
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container,
notify
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开抽屉'));
expect(container).toMatchSnapshot();
await waitFor(() => {
expect(getByText('确认')).toBeInTheDocument();
});
fireEvent.click(getByText('确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('取消')).toBeInTheDocument();
});
fireEvent.click(getByText('取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
// actions
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('关闭当前抽屉')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭当前抽屉'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('打开子抽屉')).toBeInTheDocument();
});
fireEvent.click(getByText('打开子抽屉'));
await waitFor(() => {
expect(getByText('关闭父抽屉')).toBeInTheDocument();
});
fireEvent.click(getByText('关闭父抽屉'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('触发确认')).toBeInTheDocument();
});
fireEvent.click(getByText('触发确认'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(getByText('触发取消')).toBeInTheDocument();
});
fireEvent.click(getByText('触发取消'));
await wait(300);
expect(notify).toHaveBeenCalled();
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
}, 7000);
test('EventAction:drawer data', async () => {
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
data: {
name: 'amis'
},
body: [
{
type: 'button',
label: '打开抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
args: {
drawer: {
type: 'drawer',
id: 'drawer_001',
title: '模态弹窗${event.data.name}',
body: [
{
type: 'tpl',
tpl: '你好,我是${name}、${name1}、${name2}'
}
],
data: {
name1: '${name}',
name2: '${event.data.name}'
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).toBeInTheDocument();
expect(getByText('模态弹窗')).toBeInTheDocument();
expect(getByText('你好,我是、amis、amis')).toBeInTheDocument(); // 因为事件动作给args提前做了映射
});
}, 7000);
test('EventAction:drawer data2', async () => {
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
data: {
name: 'amis'
},
body: [
{
type: 'button',
label: '打开抽屉',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
drawer: {
type: 'drawer',
id: 'drawer_001',
title: '模态弹窗${event.data.name}',
body: [
{
type: 'tpl',
tpl: '你好,我是${name}、${name1}、${name2}'
}
],
data: {
name1: '${name}',
name2: '${event.data.name}'
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
// events
fireEvent.click(getByText('打开抽屉'));
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).toBeInTheDocument();
expect(getByText('模态弹窗')).toBeInTheDocument();
expect(getByText('你好,我是、amis、amis')).toBeInTheDocument();
});
}, 7000);

View File

@@ -0,0 +1,46 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('EventAction:email', async () => {
window.open = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '发送邮件',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'email',
args: {
to: 'amis@baidu.com',
cc: 'baidu@baidu.com',
subject: '这是邮件主题',
body: '这是邮件正文'
}
}
]
}
}
}
]
},
{},
makeEnv({})
)
);
fireEvent.click(getByText('发送邮件'));
await waitFor(() => {
expect(window.open).toHaveBeenCalledWith(
'mailto:amis@baidu.com?cc=baidu%40baidu.com&subject=%E8%BF%99%E6%98%AF%E9%82%AE%E4%BB%B6%E4%B8%BB%E9%A2%98&body=%E8%BF%99%E6%98%AF%E9%82%AE%E4%BB%B6%E6%AD%A3%E6%96%87'
);
});
});

View File

@@ -0,0 +1,88 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('EventAction:hidden', async () => {
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
btnHidden: true,
btnNotHidden: false
},
body: [
{
type: 'action',
label: '按钮1',
hiddenOn: '${btnHidden}'
},
{
type: 'action',
label: '按钮2',
className: 'btn_2',
hiddenOn: '${btnNotHidden}',
onEvent: {
click: {
actions: [
{
actionType: 'hidden',
componentId: 'ui:button_test_3'
}
]
}
}
},
{
type: 'action',
label: '按钮3',
className: 'btn_3',
hiddenOn: '${btnNotHidden}',
id: 'ui:button_test_3'
},
{
type: 'action',
label: '按钮4',
className: 'btn_4',
hiddenOn: '${btnNotHidden}',
onEvent: {
click: {
actions: [
{
actionType: 'show',
componentId: 'ui:button_test_5'
}
]
}
}
},
{
type: 'action',
label: '按钮5',
className: 'btn_5',
hidden: true,
id: 'ui:button_test_5'
}
]
},
{},
makeEnv({})
)
);
await waitFor(() => {
expect(container.querySelector('.btn_2')).toBeInTheDocument();
expect(container.querySelector('.btn_3')).toBeInTheDocument();
expect(container.querySelector('.btn_4')).toBeInTheDocument();
expect(container.querySelector('.btn_5')).not.toBeInTheDocument();
});
fireEvent.click(getByText(/按钮2/));
await wait(300);
expect(container.querySelector('.btn_3')).not.toBeInTheDocument();
fireEvent.click(getByText(/按钮4/));
await wait(300);
expect(container.querySelector('.btn_5')).toBeInTheDocument();
});

View File

@@ -0,0 +1,172 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('EventAction:prevent', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
age: 18
}
}
})
);
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
className: 'ml-2',
label: '打开弹窗',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
type: 'dialog',
title: '提示',
id: 'dialog_001',
data: {
myage: '22'
},
body: [
{
type: 'alert',
body: '确认后将不关闭弹窗',
level: 'warning'
}
],
onEvent: {
confirm: {
actions: [
{
actionType: 'toast',
args: {
msg: '不关闭'
},
preventDefault: true,
stopPropagation: true
},
{
actionType: 'ajax',
args: {
api: {
url: '/api/xxx',
method: 'get'
}
}
}
]
}
}
}
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container,
notify,
fetcher
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
fireEvent.click(getByText('打开弹窗'));
await waitFor(() => {
expect(getByText('确认')).toBeInTheDocument();
});
fireEvent.click(getByText('确认'));
await waitFor(() => {
expect(notify).toHaveBeenCalled();
expect(container.querySelector('[role="dialog"]')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
expect(fetcher).not.toHaveBeenCalled();
});
test('EventAction:ignoreError', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
age: 18
}
}
})
);
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '按钮',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'reload',
componentId: 'notfound',
ignoreError: true
},
{
actionType: 'ajax',
api: '/api/test3'
},
{
actionType: 'custom',
script:
"const myMsg = '我是自定义JS';\nsdfsdfsdf();\ndoAction({\n actionType: 'toast',\n args: {\n msg: myMsg\n }\n});\n",
ignoreError: true
},
{
actionType: 'ajax',
api: '/api/test4'
}
]
}
}
}
]
},
{},
makeEnv({
getModalContainer: () => container,
notify,
fetcher
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
fireEvent.click(getByText('按钮'));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/test3');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/test4');
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,646 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`doAction:page reload 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default mb-2"
type="button"
>
<span>
刷新Page数据加载请求
</span>
</button>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="title"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的标题:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="title"
placeholder=""
size="10"
type="text"
value="Test Page Component"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="age"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的年龄:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="age"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`doAction:page reload 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Spinner-overlay in"
/>
<div
class="cxd-Spinner cxd-Spinner--overlay in"
data-testid="spinner"
>
<div
class="cxd-Spinner-icon cxd-Spinner-icon--lg cxd-Spinner-icon--default"
/>
</div>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default mb-2"
type="button"
>
<span>
刷新Page数据加载请求
</span>
</button>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="title"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的标题:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="title"
placeholder=""
size="10"
type="text"
value="Test Page Component"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="age"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的年龄:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="age"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`doAction:page reload with data 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default mb-2"
type="button"
>
<span>
刷新Page数据加载请求,同时把年龄更新为18
</span>
</button>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="title"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的标题:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="title"
placeholder=""
size="10"
type="text"
value="Test Page Component"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="age"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的年龄:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="age"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`doAction:page reload with data 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Spinner-overlay in"
/>
<div
class="cxd-Spinner cxd-Spinner--overlay in"
data-testid="spinner"
>
<div
class="cxd-Spinner-icon cxd-Spinner-icon--lg cxd-Spinner-icon--default"
/>
</div>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default mb-2"
type="button"
>
<span>
刷新Page数据加载请求,同时把年龄更新为18
</span>
</button>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="title"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的标题:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="title"
placeholder=""
size="10"
type="text"
value="Test Page Component"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="age"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的年龄:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="age"
placeholder=""
size="10"
type="text"
value="18"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`doAction:page reload with data(same name) 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default mb-2"
type="button"
>
<span>
刷新Page数据加载请求,请求返回的date会覆盖动作传递的date
</span>
</button>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="title"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的标题:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="title"
placeholder=""
size="10"
type="text"
value="Test Page Component"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="date"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
日期:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="date"
placeholder=""
size="10"
type="text"
value="2017-10-13"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`doAction:page reload with data(same name) 2`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Spinner-overlay"
/>
<div
class="cxd-Spinner cxd-Spinner--overlay"
data-testid="spinner"
>
<div
class="cxd-Spinner-icon cxd-Spinner-icon--lg cxd-Spinner-icon--default"
/>
</div>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default mb-2"
type="button"
>
<span>
刷新Page数据加载请求,请求返回的date会覆盖动作传递的date
</span>
</button>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="title"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
我的标题:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="title"
placeholder=""
size="10"
type="text"
value="Test Page Component"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="date"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
日期:
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="date"
placeholder=""
size="10"
type="text"
value="2017-10-13"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,87 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('EventAction:action', async () => {
const notify = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
btnDisabled: true,
btnNotDisabled: false
},
body: [
{
type: 'button',
label: 'action',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
mouseenter: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
mouseleave: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}
}
}
]
},
{},
makeEnv({
notify
})
)
);
fireEvent.click(getByText('action'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发点击事件', {
msg: '派发点击事件',
msgType: 'info'
});
});
fireEvent.mouseEnter(getByText('action'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移入事件', {
msg: '派发鼠标移入事件',
msgType: 'info'
});
});
fireEvent.mouseLeave(getByText('action'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移出事件', {
msg: '派发鼠标移出事件',
msgType: 'info'
});
});
});

View File

@@ -0,0 +1,87 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('EventAction:avatar', async () => {
const notify = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
btnDisabled: true,
btnNotDisabled: false
},
body: [
{
type: 'avatar',
text: 'AM',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
mouseenter: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
mouseleave: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}
}
}
]
},
{},
makeEnv({
notify
})
)
);
const avatar = container.querySelector('.cxd-Avatar');
fireEvent.click(avatar);
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发点击事件', {
msg: '派发点击事件',
msgType: 'info'
});
});
fireEvent.mouseEnter(avatar);
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移入事件', {
msg: '派发鼠标移入事件',
msgType: 'info'
});
});
fireEvent.mouseLeave(avatar);
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移出事件', {
msg: '派发鼠标移出事件',
msgType: 'info'
});
});
});

View File

@@ -0,0 +1,75 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('EventAction:collapse', async () => {
const notify = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {},
body: [
{
type: 'collapse',
header: '折叠器',
body: [
{
type: 'tpl',
tpl: '内容',
wrapperComponent: '',
inline: false
}
],
onEvent: {
expand: {
weight: 0,
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发展开事件'
}
}
]
},
collapse: {
weight: 0,
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发收起事件'
}
}
]
}
}
}
]
},
{},
makeEnv({
notify
})
)
);
fireEvent.click(getByText('折叠器'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发收起事件', {
msg: '派发收起事件',
msgType: 'info'
});
});
fireEvent.click(getByText('折叠器'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发展开事件', {
msg: '派发展开事件',
msgType: 'info'
});
});
});

View File

@@ -0,0 +1,82 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('EventAction:container', async () => {
const notify = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'container',
body: '这里是容器内容区',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
mouseenter: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
mouseleave: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}
}
}
]
},
{},
makeEnv({
notify
})
)
);
fireEvent.click(getByText('这里是容器内容区'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发点击事件', {
msg: '派发点击事件',
msgType: 'info'
});
});
fireEvent.mouseEnter(getByText('这里是容器内容区'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移入事件', {
msg: '派发鼠标移入事件',
msgType: 'info'
});
});
fireEvent.mouseLeave(getByText('这里是容器内容区'));
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移出事件', {
msg: '派发鼠标移出事件',
msgType: 'info'
});
});
});

View File

@@ -0,0 +1,582 @@
import React = require('react');
import * as renderer from 'react-test-renderer';
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, replaceReactAriaIds, wait} from '../../helper';
test('doAction:crud reload', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
count: 171,
rows: [
{
engine: 'Trident - pbz7l',
browser: 'Internet Explorer 4.0',
platform: 'Win 95+',
version: '4',
grade: 'X',
badgeText: '默认',
id: 1
},
{
engine: 'Trident - tir4m8',
browser: 'Internet Explorer 5.0',
platform: 'Win 95+',
version: '5',
grade: 'C',
badgeText: '危险',
id: 2
},
{
engine: 'Trident - wcn6f',
browser: 'Internet Explorer 5.5',
platform: 'Win 95+',
version: '5.5',
grade: 'A',
id: 3
},
{
engine: 'Trident - uwmcbf',
browser: 'Internet Explorer 6',
platform: 'Win 98+',
version: '6',
grade: 'A',
id: 4
},
{
engine: 'Trident - yjgst7',
browser: 'Internet Explorer 7',
platform: 'Win XP SP2+',
version: '7',
grade: 'A',
id: 5
},
{
engine: 'Trident - w9ee2k',
browser: 'AOL browser (AOL desktop)',
platform: 'Win XP',
version: '6',
grade: 'A',
id: 6
},
{
engine: 'Gecko - hi6cd',
browser: 'Firefox 1.0',
platform: 'Win 98+ / OSX.2+',
version: '1.7',
grade: 'A',
id: 7
},
{
engine: 'Gecko - 4kxz6',
browser: 'Firefox 1.5',
platform: 'Win 98+ / OSX.2+',
version: '1.8',
grade: 'A',
id: 8
},
{
engine: 'Gecko - x0u91o',
browser: 'Firefox 2.0',
platform: 'Win 98+ / OSX.2+',
version: '1.8',
grade: 'A',
id: 9
},
{
engine: 'Gecko - iou01',
browser: 'Firefox 3.0',
platform: 'Win 2k+ / OSX.3+',
version: '1.9',
grade: 'A',
id: 10
}
]
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
data: {
name: 'amis',
age: 18,
date: '2023-6-6'
},
body: [
{
type: 'button',
label: '刷新CRUD数据加载请求',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'crud_reload',
actionType: 'reload'
}
]
}
}
},
{
type: 'crud',
api: '/api/mock2/sample',
id: 'crud_reload',
syncLocation: false,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'engine',
label: 'Rendering engine'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'platform',
label: 'Platform(s)'
},
{
name: 'version',
label: 'Engine version'
},
{
name: 'grade',
label: 'CSS grade'
},
{
type: 'operation',
label: '操作',
buttons: [
{
label: '详情',
type: 'button',
level: 'link',
actionType: 'dialog',
dialog: {
title: '查看详情',
body: {
type: 'form',
body: [
{
type: 'input-text',
name: 'engine',
label: 'Engine'
},
{
type: 'input-text',
name: 'browser',
label: 'Browser'
},
{
type: 'input-text',
name: 'platform',
label: 'platform'
},
{
type: 'input-text',
name: 'version',
label: 'version'
},
{
type: 'control',
label: 'grade',
body: {
type: 'tag',
label: '${grade}',
displayMode: 'normal',
color: 'active'
}
}
]
}
}
},
{
label: '删除',
type: 'button',
level: 'link',
className: 'text-danger',
disabledOn: "this.grade === 'A'"
}
]
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(getByText('刷新CRUD数据加载请求')).toBeInTheDocument();
});
fireEvent.click(getByText(/刷新CRUD数据加载请求/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual(
'/api/mock2/sample?page=1&perPage=10'
);
expect(fetcher.mock.calls[1][0].url).toEqual(
'/api/mock2/sample?page=1&perPage=10'
);
});
await wait(500);
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});
test('doAction:crud reload with data1', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688714086
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
data: {
name: 'amis',
age: 18,
date: '2023-6-6'
},
body: [
{
type: 'button',
label: '刷新CRUD数据加载请求,同时追加参数date',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'crud_reload',
actionType: 'reload',
data: {
date: '${date}'
}
}
]
}
}
},
{
type: 'crud',
api: '/api/mock2/sample',
id: 'crud_reload',
syncLocation: false,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'engine',
label: 'Rendering engine'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'platform',
label: 'Platform(s)'
},
{
name: 'version',
label: 'Engine version'
},
{
name: 'grade',
label: 'CSS grade'
},
{
type: 'operation',
label: '操作',
buttons: [
{
label: '详情',
type: 'button',
level: 'link',
actionType: 'dialog',
dialog: {
title: '查看详情',
body: {
type: 'form',
body: [
{
type: 'input-text',
name: 'engine',
label: 'Engine'
},
{
type: 'input-text',
name: 'browser',
label: 'Browser'
},
{
type: 'input-text',
name: 'platform',
label: 'platform'
},
{
type: 'input-text',
name: 'version',
label: 'version'
},
{
type: 'control',
label: 'grade',
body: {
type: 'tag',
label: '${grade}',
displayMode: 'normal',
color: 'active'
}
}
]
}
}
},
{
label: '删除',
type: 'button',
level: 'link',
className: 'text-danger',
disabledOn: "this.grade === 'A'"
}
]
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
getByText('刷新CRUD数据加载请求,同时追加参数date')
).toBeInTheDocument();
});
fireEvent.click(getByText(/刷新CRUD数据加载请求,同时追加参数date/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual(
'/api/mock2/sample?page=1&perPage=10'
);
expect(fetcher.mock.calls[1][0].url).toEqual(
'/api/mock2/sample?page=1&date=2023-6-6&perPage=10'
);
});
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});
test('doAction:crud reload with data2', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688714086
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
data: {
name: 'amis',
age: 18,
date: '2023-6-6'
},
body: [
{
type: 'button',
label: '刷新CRUD数据加载请求,同时追加按钮所在数据域的所有数据',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'crud_reload',
actionType: 'reload',
data: {
'&': '$$',
'author': 'fex'
}
}
]
}
}
},
{
type: 'crud',
api: '/api/mock2/sample',
id: 'crud_reload',
syncLocation: false,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'engine',
label: 'Rendering engine'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'platform',
label: 'Platform(s)'
},
{
name: 'version',
label: 'Engine version'
},
{
name: 'grade',
label: 'CSS grade'
},
{
type: 'operation',
label: '操作',
buttons: [
{
label: '详情',
type: 'button',
level: 'link',
actionType: 'dialog',
dialog: {
title: '查看详情',
body: {
type: 'form',
body: [
{
type: 'input-text',
name: 'engine',
label: 'Engine'
},
{
type: 'input-text',
name: 'browser',
label: 'Browser'
},
{
type: 'input-text',
name: 'platform',
label: 'platform'
},
{
type: 'input-text',
name: 'version',
label: 'version'
},
{
type: 'control',
label: 'grade',
body: {
type: 'tag',
label: '${grade}',
displayMode: 'normal',
color: 'active'
}
}
]
}
}
},
{
label: '删除',
type: 'button',
level: 'link',
className: 'text-danger',
disabledOn: "this.grade === 'A'"
}
]
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
getByText('刷新CRUD数据加载请求,同时追加按钮所在数据域的所有数据')
).toBeInTheDocument();
});
fireEvent.click(
getByText(/刷新CRUD数据加载请求,同时追加按钮所在数据域的所有数据/)
);
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual(
'/api/mock2/sample?page=1&perPage=10'
);
expect(fetcher.mock.calls[1][0].url).toEqual(
'/api/mock2/sample?page=1&name=amis&age=18&date=2023-6-6&author=fex&perPage=10'
);
});
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,428 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EventAction:inputRange 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="range"
data-role="form-item"
>
<div
class="cxd-RangeControl cxd-InputRange cxd-Form-control"
>
<div
class="cxd-InputRange-wrap"
>
<div
class="cxd-InputRange-track cxd-InputRange-track--background"
>
<div
class="cxd-InputRange-track-active"
style="width: 0%; left: 0%;"
/>
<div
class="cxd-InputRange-handle"
style="left: 0%; z-index: 1;"
>
<div
class="cxd-InputRange-handle-icon"
>
<icon-mock
classname="icon icon-slider-handle"
icon="slider-handle"
/>
</div>
<div
class="cxd-InputRange-label pos-top"
>
<span>
0
</span>
</div>
</div>
</div>
</div>
<div
class="cxd-InputRange-input"
>
<div
class="cxd-Number cxd-Number--borderFull"
>
<div
class="cxd-Number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="cxd-Number-handler cxd-Number-handler-up"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-up-inner"
unselectable="on"
/>
</span>
<span
aria-disabled="true"
aria-label="Decrease Value"
class="cxd-Number-handler cxd-Number-handler-down cxd-Number-handler-down-disabled"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-down-inner"
unselectable="on"
/>
</span>
</div>
<div
class="cxd-Number-input-wrap"
>
<input
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
autocomplete="off"
class="cxd-Number-input"
role="spinbutton"
step="1"
value="0"
/>
</div>
</div>
</div>
<a
class="cxd-InputRange-clear"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
</div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-JsonField cxd-Form--debug"
>
<div
class="react-json-view"
style="font-family: monospace; cursor: default; background-color: rgba(0, 0, 0, 0); position: relative;"
>
<div
class="pretty-json-container object-container"
>
<div
class="object-content"
>
<div
class="object-key-val"
>
<span>
<span
style="display: inline-block; cursor: pointer;"
>
<div
class="icon-container"
style="display: inline-block; width: 17px;"
>
<span
class="expanded-icon"
>
<svg
fill="#586e75"
height="1em"
style="vertical-align: middle; color: rgb(88, 110, 117); height: 1em; width: 1em;"
viewBox="0 0 1792 1792"
width="1em"
>
<path
d="M1344 800v64q0 14-9 23t-23 9h-832q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"
/>
</svg>
</span>
</div>
<span />
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54);"
>
{
</span>
</span>
<div
class="object-meta-data"
style="display: inline-block; padding: 0px 0px 0px 10px;"
>
<span
class="object-size"
style="color: rgba(0, 0, 0, 0.3); border-radius: 3px; font-style: italic; margin: 0px 6px 0px 0px; cursor: default;"
>
2
item
s
</span>
</div>
</span>
<div
class="pushed-content object-container"
>
<div
class="object-content"
style="margin-left: 6px;"
>
<div
class="variable-row"
style="border-left: 1px solid rgb(235, 235, 235); padding: 3px 5px 3px 20px;"
>
<span>
<span
class="object-key"
style="display: inline-block; color: rgb(0, 43, 54); letter-spacing: 0.5px; font-style: none; vertical-align: top; opacity: 0.85;"
>
<span
style="vertical-align: top;"
>
"
</span>
<span
style="display: inline-block;"
>
rangeValue
</span>
<span
style="vertical-align: top;"
>
"
</span>
</span>
<span
style="display: inline-block; margin: 0px 5px; color: rgb(0, 43, 54); vertical-align: top;"
>
:
</span>
</span>
<div
class="variable-value"
style="display: inline-block; padding-right: 6px; position: relative; cursor: default;"
>
<div
style="display: inline-block; color: rgb(203, 75, 22);"
>
<span
class="string-value"
style="cursor: default;"
>
"
值为0
"
</span>
</div>
</div>
</div>
<div
class="variable-row"
style="border-left: 1px solid rgb(235, 235, 235); padding: 3px 5px 3px 20px;"
>
<span>
<span
class="object-key"
style="display: inline-block; color: rgb(0, 43, 54); letter-spacing: 0.5px; font-style: none; vertical-align: top; opacity: 0.85;"
>
<span
style="vertical-align: top;"
>
"
</span>
<span
style="display: inline-block;"
>
rangeEvent
</span>
<span
style="vertical-align: top;"
>
"
</span>
</span>
<span
style="display: inline-block; margin: 0px 5px; color: rgb(0, 43, 54); vertical-align: top;"
>
:
</span>
</span>
<div
class="variable-value"
style="display: inline-block; padding-right: 6px; position: relative; cursor: default;"
>
<div
style="display: inline-block; color: rgb(203, 75, 22);"
>
<span
class="string-value"
style="cursor: default;"
>
"
触发了blur
"
</span>
</div>
</div>
</div>
</div>
</div>
<span
class="brace-row"
>
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54); padding-left: 3px;"
>
}
</span>
</span>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal input-text-range-value"
data-amis-name="rangeValue"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
滑块值
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl is-disabled"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
disabled=""
name="rangeValue"
placeholder=""
size="10"
type="text"
value="值为0"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal input-text-range-event"
data-amis-name="rangeEvent"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
滑块事件
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl is-disabled"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
disabled=""
name="rangeEvent"
placeholder=""
size="10"
type="text"
value="触发了blur"
/>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,225 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../../src';
import {render as amisRender} from '../../../../src';
import {makeEnv, wait} from '../../../helper';
test('EventAction:combo', async () => {
// const notify = jest.fn();
// const {getByText, container}: any = render(
// amisRender(
// {
// type: 'page',
// title: 'combo',
// body: [
// {
// type: 'form',
// id: 'u:71e9bb1ed157',
// title: '表单',
// data: {
// combo: [
// {
// name: 'Tom',
// age: 18
// },
// {
// name: 'Jerry',
// age: 22
// }
// ]
// },
// body: [
// {
// type: 'button',
// label: '更新数据',
// onEvent: {
// click: {
// actions: [
// {
// actionType: 'setValue',
// componentId: 'u:54031932ab8c',
// args: {
// value: [
// {
// name: 'Jack',
// age: 22
// }
// ]
// }
// }
// ]
// }
// }
// },
// {
// type: 'button',
// label: 'clear',
// onEvent: {
// click: {
// actions: [
// {
// actionType: 'clear',
// componentId: 'u:54031932ab8c'
// }
// ]
// }
// }
// },
// {
// type: 'button',
// label: 'reset',
// onEvent: {
// click: {
// actions: [
// {
// actionType: 'reset',
// componentId: 'u:54031932ab8c'
// }
// ]
// }
// }
// },
// {
// type: 'combo',
// label: '组合输入',
// name: 'combo',
// id: 'u:54031932ab8c',
// multiple: true,
// tabsMode: true,
// resetValue: [
// {
// name: 'Tom',
// age: 18
// }
// ],
// items: [
// {
// type: 'input-text',
// name: 'name'
// },
// {
// type: 'input-text',
// name: 'age'
// },
// {
// type: 'button',
// label: '自增第${index}项的年龄',
// onEvent: {
// click: {
// actions: [
// {
// actionType: 'setValue',
// componentId: 'u:54031932ab8c',
// args: {
// value: {
// age: '${age+1}'
// },
// index: '${index}'
// }
// }
// ]
// }
// }
// }
// ],
// onEvent: {
// add: {
// actions: [
// {
// actionType: 'toast',
// args: {
// msgType: 'info',
// msg: '派发新增事件'
// }
// }
// ]
// },
// delete: {
// actions: [
// {
// actionType: 'toast',
// args: {
// msgType: 'info',
// msg: '派发删除事件'
// }
// }
// ]
// },
// tabsChange: {
// actions: [
// {
// actionType: 'toast',
// args: {
// msgType: 'info',
// msg: '派发选项卡切换事件'
// }
// }
// ]
// }
// }
// }
// ]
// }
// ]
// },
// {},
// makeEnv({
// notify
// })
// )
// );
// await waitFor(() => {
// expect(getByText('新增')).toBeInTheDocument();
// });
// fireEvent.click(getByText('新增'));
// await waitFor(() => {
// expect(notify).toHaveBeenCalledWith('info', '派发新增事件', {
// msg: '派发新增事件',
// msgType: 'info'
// });
// });
// fireEvent.click(
// container.querySelectorAll(
// 'div[data-tooltip="删除"]'
// )[1] as HTMLInputElement
// );
// await waitFor(() => {
// expect(notify).toHaveBeenCalledWith('info', '派发删除事件', {
// msg: '派发删除事件',
// msgType: 'info'
// });
// expect(notify).toHaveBeenCalledWith('info', '派发选项卡切换事件', {
// msg: '派发选项卡切换事件',
// msgType: 'info'
// });
// });
// await waitFor(() => {
// expect(getByText('自增第0项的年龄')).toBeInTheDocument();
// });
// fireEvent.click(getByText('自增第0项的年龄'));
// await waitFor(() => {
// expect(
// container.querySelector('input[name=age]')?.getAttribute('value')
// ).toBe('19');
// });
// await waitFor(() => {
// expect(getByText('更新数据')).toBeInTheDocument();
// });
// fireEvent.click(getByText('更新数据'));
// await waitFor(() => {
// expect(
// container.querySelector('input[name=name]')?.getAttribute('value')
// ).toBe('Jack');
// });
// fireEvent.click(getByText('reset'));
// await waitFor(() => {
// expect(
// container.querySelector('input[name=name]')?.getAttribute('value')
// ).toBe('Tom');
// });
// fireEvent.click(getByText('clear'));
// await waitFor(() => {
// expect(
// container.querySelector('div[class="cxd-Tabs-content"]')
// ).toBeEmptyDOMElement();
// });
});

View File

@@ -0,0 +1,960 @@
import React = require('react');
import * as renderer from 'react-test-renderer';
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../../src';
import {render as amisRender} from '../../../../src';
import {makeEnv, wait} from '../../../helper';
test('doAction:form validate', async () => {
const notify = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '校验表单',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'validate',
componentId: 'form_validate',
outputVar: 'form_validate_result'
},
{
actionType: 'setValue',
componentId: 'validate_info',
args: {
value: '${event.data.form_validate_result|json}'
}
}
]
}
}
},
{
type: 'input-text',
name: 'validate_info',
id: 'validate_info',
label: '验证信息:'
},
{
type: 'form',
id: 'form_validate',
api: '/api/mock2/form/saveForm',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:',
required: true
},
{
name: 'email',
type: 'input-text',
label: '邮箱:',
required: true,
validations: {
isEmail: true
}
}
]
}
]
},
{},
makeEnv({
notify
})
)
);
await waitFor(() => {
expect(getByText('校验表单')).toBeInTheDocument();
});
fireEvent.click(getByText(/校验表单/));
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual(
`{ "error": "依赖的部分字段没有通过验证", "errors": { "name": [ "这是必填项" ], "email": [ "这是必填项" ] }, "payload": {}}`
);
});
expect(container).toMatchSnapshot();
fireEvent.change(container.querySelector('[name="name"]')!, {
target: {value: 'amis'}
});
fireEvent.change(container.querySelector('[name="email"]')!, {
target: {value: 'amis@baidu.com'}
});
await waitFor(() => {
expect(container.querySelector('[value="amis"]')).toBeInTheDocument();
expect(
container.querySelector('[value="amis@baidu.com"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.change(container.querySelector('[name="validate_info"]')!, {
target: {value: ''}
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual('');
});
fireEvent.click(getByText(/校验表单/));
await waitFor(() => {
expect(
container.querySelector('.is-error .is-required .has-error--isRequired')
).not.toBeInTheDocument();
});
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual(
`{ "error": "", "payload": { "name": "amis", "email": "amis@baidu.com" }}`
);
});
expect(container).toMatchSnapshot();
});
test('doAction:form submit', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
id: 1
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '提交表单',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'submit',
componentId: 'form_submit',
outputVar: 'form_submit_result'
},
{
actionType: 'setValue',
componentId: 'submit_info',
args: {
value: '${event.data.form_submit_result|json}'
}
}
]
}
}
},
{
type: 'input-text',
name: 'submit_info',
id: 'submit_info',
label: '提交信息:'
},
{
type: 'form',
id: 'form_submit',
api: '/api/mock2/form/saveForm',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:',
required: true
},
{
name: 'email',
type: 'input-text',
label: '邮箱:',
required: true,
validations: {
isEmail: true
}
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(getByText('提交表单')).toBeInTheDocument();
});
fireEvent.click(getByText(/提交表单/));
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="submit_info"]') as any)?.value
).toEqual(
`{ "error": "依赖的部分字段没有通过验证", "errors": { "name": [ "这是必填项" ], "email": [ "这是必填项" ] }, "payload": {}}`
);
});
expect(container).toMatchSnapshot();
fireEvent.change(container.querySelector('[name="name"]')!, {
target: {value: 'amis'}
});
fireEvent.change(container.querySelector('[name="email"]')!, {
target: {value: 'amis@baidu.com'}
});
await waitFor(() => {
expect(container.querySelector('[value="amis"]')).toBeInTheDocument();
expect(
container.querySelector('[value="amis@baidu.com"]')
).toBeInTheDocument();
});
fireEvent.change(container.querySelector('[name="submit_info"]')!, {
target: {value: ''}
});
await waitFor(() => {
expect(
(container.querySelector('[name="submit_info"]') as any)?.value
).toEqual('');
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/提交表单/));
await waitFor(() => {
expect(
container.querySelector('.is-error .is-required .has-error--isRequired')
).not.toBeInTheDocument();
});
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="submit_info"]') as any)?.value
).toEqual(
`{ "error": "", "payload": { "name": "amis", "email": "amis@baidu.com" }, "responseData": { "id": 1 }}`
);
});
expect(container).toMatchSnapshot();
});
test('doAction:form force validate before submit', async () => {
const notify = jest.fn();
const {container, getByText, queryByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
body: [
{
type: 'input-text',
name: 'value1',
validations: {
equalsField: 'value2'
},
value: 1
},
{
name: 'value2',
type: 'input-text',
validations: {
equalsField: 'value1'
}
}
]
}
]
},
{},
makeEnv({
notify
})
)
);
await waitFor(() => {
expect(getByText('提交')).toBeInTheDocument();
});
fireEvent.click(getByText(/提交/));
await wait(300);
await waitFor(() => {
expect(queryByText('输入的数据与 value2 值不一致')).toBeInTheDocument();
expect(queryByText('输入的数据与 value1 值不一致')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.change(container.querySelector('[name="value2"]')!, {
target: {value: '1'}
});
await wait(300);
await waitFor(() => {
expect(queryByText('输入的数据与 value1 值不一致')).not.toBeInTheDocument();
});
fireEvent.click(getByText(/提交/));
await wait(300);
await waitFor(() => {
expect(queryByText('输入的数据与 value2 值不一致')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:form setValue', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
id: 1
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '修改表单数据',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'form_setvalue',
args: {
value: {
name: 'amis',
email: 'amis@baidu.com'
}
}
}
]
}
}
},
{
type: 'form',
id: 'form_setvalue',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'email',
type: 'input-text',
label: '邮箱:'
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(getByText('修改表单数据')).toBeInTheDocument();
});
fireEvent.click(getByText(/修改表单数据/));
await waitFor(() => {
expect(container.querySelector('[value="amis"]')).toBeInTheDocument();
expect(
container.querySelector('[value="amis@baidu.com"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:form reload default', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688714086
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '刷新表单',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'reload',
componentId: 'form_reload'
}
]
}
}
},
{
type: 'form',
id: 'form_reload',
debug: true,
initApi: '/api/mock2/form/initData',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'author',
type: 'input-text',
label: '作者:'
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await wait(500); // 等待 initApi 加载完
expect(
(container.querySelector('[name="author"]') as HTMLInputElement).value
).toEqual('fex');
const author: HTMLInputElement = container.querySelector('[name="author"]')!;
fireEvent.change(author, {
target: {value: 'amis'}
});
expect(
(container.querySelector('[name="author"]') as HTMLInputElement).value
).toEqual('amis');
// expect(container).toMatchSnapshot();
await wait(200);
expect(getByText('刷新表单')).toBeInTheDocument();
fireEvent.click(getByText('刷新表单'));
await wait(200);
expect(
(container.querySelector('[name="author"]') as HTMLInputElement).value
).toEqual('fex');
// expect(container).toMatchSnapshot();
});
test('doAction:form reload with data', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688714086
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '刷新表单',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'reload',
componentId: 'form_reload',
data: {
age: 18
}
}
]
}
}
},
{
type: 'form',
id: 'form_reload',
debug: true,
initApi: '/api/mock2/form/initData',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'author',
type: 'input-text',
label: '作者:'
},
{
name: 'age',
type: 'input-text',
label: '年龄:'
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await wait(500);
const author: HTMLInputElement = container.querySelector('[name="author"]')!;
expect(author).toBeInTheDocument();
fireEvent.change(author, {
target: {value: 'amis'}
});
await wait(200);
expect(author.value).toEqual('amis');
expect(getByText('刷新表单')).toBeInTheDocument();
fireEvent.click(getByText('刷新表单'));
await wait(200);
expect(author.value).toEqual('fex');
expect((container.querySelector('[name="age"]') as any)?.value).toEqual('18');
});
test('doAction:form reset', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688714086
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '重置表单',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'form_reset'
}
]
}
}
},
{
type: 'form',
id: 'form_reset',
initApi: '/api/mock2/form/initData',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'author',
type: 'input-text',
label: '作者:'
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
fireEvent.change(container.querySelector('[name="author"]')!, {
target: {value: 'amis'}
});
await waitFor(() => {
expect((container.querySelector('[name="author"]') as any)?.value).toEqual(
'amis'
);
});
expect(container).toMatchSnapshot();
await waitFor(() => {
expect(getByText('重置表单')).toBeInTheDocument();
});
fireEvent.click(getByText(/重置表单/));
await waitFor(() => {
expect((container.querySelector('[name="author"]') as any)?.value).toEqual(
'fex'
);
});
expect(container).toMatchSnapshot();
});
test('doAction:form clear', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688714086
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '清空表单',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'form_clear'
}
]
}
}
},
{
type: 'form',
id: 'form_clear',
debug: true,
initApi: '/api/mock2/form/initData',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'author',
type: 'hidden',
label: '作者:'
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await wait(500);
await waitFor(() => {
expect(getByText('清空表单')).toBeInTheDocument();
});
fireEvent.click(getByText(/清空表单/));
await waitFor(() => {
expect(
container.querySelector('[value="Amis Renderer"]')
).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:form static&nonstatic', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688714086
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '静态模式',
className: 'mr-2 mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'static',
componentId: 'form_static'
}
]
}
}
},
{
type: 'button',
label: '编辑模式',
className: 'mr-2 mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'nonstatic',
componentId: 'form_static'
}
]
}
}
},
{
type: 'form',
id: 'form_static',
title: '表单',
body: [
{
type: 'input-text',
name: 'text',
label: '输入框',
mode: 'horizontal',
value: 'text'
}
]
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(getByText('静态模式')).toBeInTheDocument();
});
fireEvent.click(getByText(/静态模式/));
await waitFor(() => {
expect(container.querySelector('.cxd-Form-static')).toBeInTheDocument();
expect(
container.querySelector('.cxd-TextControl-input')
).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
await waitFor(() => {
expect(getByText('编辑模式')).toBeInTheDocument();
});
fireEvent.click(getByText(/编辑模式/));
await waitFor(() => {
expect(
container.querySelector('.cxd-TextControl-input')
).toBeInTheDocument();
expect(container.querySelector('.cxd-Form-static')).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:form valdiate requiredOn', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
submitText: '提交表单',
body: [
{
type: 'switch',
name: 'a',
label: 'a'
},
{
type: 'input-text',
name: 'b',
requiredOn: '${a}',
label: 'b'
}
]
},
{
onSubmit
},
makeEnv({})
)
);
fireEvent.click(getByText('提交表单'));
await wait(200);
expect(onSubmit).toBeCalled();
expect(container.querySelector('.cxd-Switch')!).toBeInTheDocument();
fireEvent.click(container.querySelector('.cxd-Switch')!);
await wait(300);
fireEvent.click(getByText('提交表单'));
await wait(300);
const ul = container.querySelector('.cxd-Form-feedback');
expect(ul).toBeInTheDocument();
fireEvent.change(container.querySelector('input[name="b"]')!, {
target: {value: '123'}
});
fireEvent.click(getByText('提交表单'));
await wait(200);
expect(onSubmit).toBeCalledTimes(2);
expect(onSubmit.mock.calls[1][0]).toMatchObject({
a: true,
b: '123'
});
expect(container.querySelector('.cxd-Form-feedback')).toBeNull();
fireEvent.change(container.querySelector('input[name="b"]')!, {
target: {value: ''}
});
await wait(300);
expect(container.querySelector('.cxd-Form-feedback')).toBeInTheDocument();
fireEvent.click(container.querySelector('.cxd-Switch')!);
await wait(300);
expect(container.querySelector('.cxd-Form-feedback')).toBeNull();
});

View File

@@ -0,0 +1,119 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../../src';
import {render as amisRender} from '../../../../src';
import {makeEnv, wait} from '../../../helper';
test('EventAction:locationPicker', async () => {
const notify = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'location-picker',
id: 'location-picker',
ak: 'LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7',
coordinatesType: 'bd09',
name: 'location',
resetValue: {
address: '北京市东城区天安门广场中央',
lat: 39.910966,
lng: 116.404165,
city: '北京'
},
onEvent: {
change: {
actions: [
{
actionType: 'setValue',
componentId: 'form',
args: {
value: {
location: '${event.data.value | json}'
}
}
}
]
}
}
},
{
type: 'form',
id: 'form',
debug: true,
body: [
{
type: 'input-text',
label: '位置信息:',
name: 'location',
id: 'input-text'
}
]
},
{
type: 'button',
label: '赋值',
id: 'u:d2662e693f82',
className: 'button-set-value',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
args: {
value: {
address: '北京市东城区天安门内',
lat: 39.914912,
lng: 116.403982,
city: '北京'
}
},
componentId: 'location-picker'
}
]
}
}
},
{
type: 'button',
label: '重置',
id: 'u:a1d92fc92cbb',
className: 'button-reset',
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'location-picker'
}
]
}
}
}
]
},
{},
makeEnv({
notify
})
)
);
await wait(500);
const buttonSetValue = container.querySelector('.button-set-value');
fireEvent.click(buttonSetValue!);
await wait(300);
await waitFor(() => {
expect(getByText('北京市东城区天安门内')).toBeInTheDocument();
});
const buttonReset = container.querySelector('.button-reset');
fireEvent.click(buttonReset!);
await wait(300);
await waitFor(() => {
expect(getByText('北京市东城区天安门广场中央')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,167 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
// import {fireEvent as fireEvent2} from '@testing-library/dom';
import '../../../../src';
import {render as amisRender} from '../../../../src';
import {makeEnv, wait} from '../../../helper';
test('EventAction:inputRange', async () => {
const notify = jest.fn();
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'input-range',
name: 'range',
value: 10,
min: 0,
showInput: true,
clearabled: true,
onEvent: {
change: {
actions: [
{
actionType: 'setValue',
componentId: 'form_data',
args: {
value: {
rangeEvent: '触发了change',
rangeValue: '值为${range}'
}
}
}
]
},
blur: {
actions: [
{
actionType: 'setValue',
componentId: 'form_data',
args: {
value: {
rangeEvent: '触发了blur',
rangeValue: '值为${range}'
}
}
}
]
},
focus: {
actions: [
{
actionType: 'setValue',
componentId: 'form_data',
args: {
value: {
rangeEvent: '触发了focus',
rangeValue: '值为${range}'
}
}
}
]
}
}
},
{
type: 'form',
id: 'form_data',
title: '表单',
debug: true,
data: {
rangeValue: '什么都没有',
rangeEvent: '什么都没触发'
},
body: [
{
type: 'input-text',
label: '滑块值',
name: 'rangeValue',
disabled: true,
className: 'input-text-range-value'
},
{
type: 'input-text',
label: '滑块事件',
name: 'rangeEvent',
disabled: true,
className: 'input-text-range-event'
}
]
}
]
},
{},
makeEnv({
notify
})
)
);
await wait(500);
const inputs = container.querySelector('.cxd-InputRange-input input')!;
// input change
const valueChange = 23;
fireEvent.change(inputs, {
target: {
value: valueChange
}
});
await wait(300);
await waitFor(() => {
expect(
container.querySelector('[value="触发了change"]')
).toBeInTheDocument();
expect(
container.querySelector(`[value="值为${valueChange}"]`)
).toBeInTheDocument();
});
/**
* 滑动 change case先注释掉,因为fireEvent.mouseMove时,event中拿不到pageX。
// 滑动 change
const slider = container.querySelector('.cxd-InputRange-handle-icon')!;
fireEvent.mouseDown(slider);
fireEvent.mouseMove(slider, {
clientX: 0,
clientY: 0
});
fireEvent.mouseUp(slider);
await wait(300);
await waitFor(() => {
expect(
container.querySelector('[value="触发了change"]')
).toBeInTheDocument();
expect(container.querySelector(`[value="值为0"]`)).toBeInTheDocument();
});
*/
// 临时替代滑动 change case
fireEvent.change(inputs, {
target: {
value: 0
}
});
await wait(300);
// focus
fireEvent.focus(inputs);
await wait(300);
await waitFor(() => {
expect(
container.querySelector('[value="触发了focus"]')
).toBeInTheDocument();
expect(container.querySelector(`[value="值为0"]`)).toBeInTheDocument();
});
// blur
fireEvent.blur(inputs);
await wait(300);
await waitFor(() => {
expect(container.querySelector('[value="触发了blur"]')).toBeInTheDocument();
expect(container.querySelector(`[value="值为0"]`)).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
}, 10000);

View File

@@ -0,0 +1,102 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../../src';
import {render as amisRender} from '../../../../src';
import {makeEnv, wait} from '../../../helper';
test('EventAction:switch', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
id: 1
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '修改开关的值',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'u:6613bfa3a18e',
actionType: 'setValue',
args: {
value: true
}
}
]
}
},
id: 'u:9d7d695145bb'
},
{
type: 'form',
title: '表单',
debug: true,
body: [
{
label: '开启',
type: 'switch',
name: 'switch',
id: 'u:6613bfa3a18e',
value: false,
mode: 'inline',
onEvent: {
change: {
actions: [
{
actionType: 'ajax',
api: '/api/mock2/form/saveForm?switch=${switch}'
}
]
}
}
}
],
id: 'u:82d44e407eb0',
actions: [
{
type: 'submit',
label: '提交',
primary: true
}
]
}
]
},
{},
makeEnv({
fetcher
})
)
);
await waitFor(() => {
expect(getByText('修改开关的值')).toBeInTheDocument();
});
fireEvent.click(getByText(/修改开关的值/));
await waitFor(() => {
expect(container.querySelector('.is-checked')).toBeInTheDocument();
});
fireEvent.click(container.querySelector('.is-checked')!);
await waitFor(() => {
expect(fetcher).toHaveBeenCalled();
expect(fetcher.mock.calls[0][0].url).toEqual(
'/api/mock2/form/saveForm?switch=false'
);
});
});

View File

@@ -0,0 +1,290 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../../src';
import {render as amisRender} from '../../../../src';
import {makeEnv, wait} from '../../../helper';
test('doAction:formItem validate', async () => {
const notify = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '校验name',
onEvent: {
click: {
actions: [
{
actionType: 'validateFormItem',
componentId: 'name_validate',
outputVar: 'form_validate_result'
},
{
actionType: 'setValue',
componentId: 'validate_info',
args: {
value: '${event.data.form_validate_result|json}'
}
}
]
}
}
},
{
type: 'button',
label: '校验email',
onEvent: {
click: {
actions: [
{
actionType: 'validateFormItem',
componentId: 'email_validate',
outputVar: 'form_validate_result'
},
{
actionType: 'setValue',
componentId: 'validate_info',
args: {
value: '${event.data.form_validate_result|json}'
}
}
]
}
}
},
{
type: 'input-text',
name: 'validate_info',
id: 'validate_info',
label: '验证信息:'
},
{
type: 'input-text',
name: 'validate_res',
id: 'validate_res',
label: '验证结果:'
},
{
type: 'form',
onEvent: {
formItemValidateSucc: {
actions: [
{
expression: '${event.data.__formName === "name"}',
actionType: 'setValue',
componentId: 'validate_res',
args: {
value: 'validate name success'
}
},
{
expression: '${event.data.__formName === "email"}',
actionType: 'setValue',
componentId: 'validate_res',
args: {
value: 'validate email success'
}
}
]
},
formItemValidateError: {
actions: [
{
expression: '${event.data.__formName === "name"}',
actionType: 'setValue',
componentId: 'validate_res',
args: {
value: 'validate name fail'
}
},
{
expression: '${event.data.__formName === "email"}',
actionType: 'setValue',
componentId: 'validate_res',
args: {
value: 'validate email fail'
}
}
]
}
},
body: [
{
type: 'input-text',
id: 'name_validate',
name: 'name',
label: '姓名:',
required: true
},
{
name: 'email',
type: 'input-text',
id: 'email_validate',
label: '邮箱:',
required: true,
validations: {
isEmail: true
}
}
]
}
]
},
{},
makeEnv({
notify
})
)
);
// 校验 name
await waitFor(() => {
expect(getByText('校验name')).toBeInTheDocument();
});
fireEvent.click(getByText(/校验name/));
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual(`{ "error": "这是必填项"}`);
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_res"]') as any)?.value
).toEqual('validate name fail');
});
expect(container).toMatchSnapshot();
// 校验 email 必填
await wait(300);
await waitFor(() => {
expect(getByText('校验email')).toBeInTheDocument();
});
fireEvent.click(getByText(/校验email/));
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual(`{ "error": "这是必填项"}`);
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_res"]') as any)?.value
).toEqual('validate email fail');
});
expect(container).toMatchSnapshot();
// 校验 email 格式
fireEvent.change(container.querySelector('[name="email"]')!, {
target: {value: 'invalid_email'}
});
await wait(300);
await waitFor(() => {
expect(
container.querySelector('[name="email"][value="invalid_email"]')
).toBeInTheDocument();
});
await waitFor(() => {
expect(getByText('校验email')).toBeInTheDocument();
});
fireEvent.click(getByText(/校验email/));
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual(`{ "error": "Email 格式不正确", "value": "invalid_email"}`);
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_res"]') as any)?.value
).toEqual('validate email fail');
});
expect(container).toMatchSnapshot();
// 填写值
fireEvent.change(container.querySelector('[name="name"]')!, {
target: {value: 'amis'}
});
await wait(300);
fireEvent.change(container.querySelector('[name="email"]')!, {
target: {value: 'amis@baidu.com'}
});
await wait(300);
await waitFor(() => {
expect(container.querySelector('[value="amis"]')).toBeInTheDocument();
expect(
container.querySelector('[value="amis@baidu.com"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
// 清空错误信息
fireEvent.change(container.querySelector('[name="validate_info"]')!, {
target: {value: ''}
});
await wait(300);
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual('');
});
// 重新校验name
fireEvent.click(getByText(/校验name/));
await wait(300);
await waitFor(() => {
expect(
container.querySelector('.is-error .is-required .has-error--isRequired')
).not.toBeInTheDocument();
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual(`{ "error": "", "value": "amis"}`);
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_res"]') as any)?.value
).toEqual('validate name success');
});
expect(container).toMatchSnapshot();
// 重新校验email
fireEvent.click(getByText(/校验email/));
await wait(300);
await waitFor(() => {
expect(
container.querySelector('.is-error .is-required .has-error--isRequired')
).not.toBeInTheDocument();
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_info"]') as any)?.value
).toEqual(`{ "error": "", "value": "amis@baidu.com"}`);
});
await waitFor(() => {
expect(
(container.querySelector('[name="validate_res"]') as any)?.value
).toEqual('validate email success');
});
expect(container).toMatchSnapshot();
}, 10000);

View File

@@ -0,0 +1,87 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('EventAction:icon', async () => {
const notify = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
btnDisabled: true,
btnNotDisabled: false
},
body: [
{
type: 'icon',
icon: 'cloud',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
mouseenter: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
mouseleave: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}
}
}
]
},
{},
makeEnv({
notify
})
)
);
const icon = container.querySelector('.cloud');
fireEvent.click(icon);
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发点击事件', {
msg: '派发点击事件',
msgType: 'info'
});
});
fireEvent.mouseEnter(icon);
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移入事件', {
msg: '派发鼠标移入事件',
msgType: 'info'
});
});
fireEvent.mouseLeave(icon);
await waitFor(() => {
expect(notify).toHaveBeenCalledWith('info', '派发鼠标移出事件', {
msg: '派发鼠标移出事件',
msgType: 'info'
});
});
});

View File

@@ -0,0 +1,285 @@
import React = require('react');
import * as renderer from 'react-test-renderer';
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('doAction:page reload', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
title: 'Test Page Component',
date: '2017-10-13'
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
initApi: '/api/mock2/page/initData',
id: 'page_reload',
body: [
{
type: 'button',
label: '刷新Page数据加载请求',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'page_reload',
actionType: 'reload'
}
]
}
}
},
{
type: 'input-text',
label: '我的标题:',
name: 'title'
},
{
type: 'input-text',
label: '我的年龄:',
name: 'age'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(getByText('刷新Page数据加载请求')).toBeInTheDocument();
expect(
container.querySelector('[name="title"][value="Test Page Component"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/刷新Page数据加载请求/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/mock2/page/initData');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/mock2/page/initData');
expect(
container.querySelector('[name="title"][value="Test Page Component"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:page reload with data', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
title: 'Test Page Component',
date: '2017-10-13'
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
initApi: '/api/mock2/page/initData',
id: 'page_reload',
body: [
{
type: 'button',
label: '刷新Page数据加载请求,同时把年龄更新为18',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'page_reload',
actionType: 'reload',
data: {
age: '18'
}
}
]
}
}
},
{
type: 'input-text',
label: '我的标题:',
name: 'title'
},
{
type: 'input-text',
label: '我的年龄:',
name: 'age'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
getByText('刷新Page数据加载请求,同时把年龄更新为18')
).toBeInTheDocument();
expect(
container.querySelector('[name="title"][value="Test Page Component"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/刷新Page数据加载请求,同时把年龄更新为18/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/mock2/page/initData');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/mock2/page/initData');
expect(
container.querySelector('[name="title"][value="Test Page Component"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value="18"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:page reload with data(same name)', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
title: 'Test Page Component',
date: '2017-10-13'
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
initApi: '/api/mock2/page/initData',
id: 'page_reload',
body: [
{
type: 'button',
label: '刷新Page数据加载请求,请求返回的date会覆盖动作传递的date',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'page_reload',
actionType: 'reload',
data: {
date: '2023-07-07'
}
}
]
}
}
},
{
type: 'input-text',
label: '我的标题:',
name: 'title'
},
{
type: 'input-text',
label: '日期:',
name: 'date'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
getByText('刷新Page数据加载请求,请求返回的date会覆盖动作传递的date')
).toBeInTheDocument();
expect(
container.querySelector('[name="title"][value="Test Page Component"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="date"][value="2017-10-13"]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(
getByText(/刷新Page数据加载请求,请求返回的date会覆盖动作传递的date/)
);
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/mock2/page/initData');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/mock2/page/initData');
expect(
container.querySelector('[name="title"][value="Test Page Component"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="date"][value="2017-10-13"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,159 @@
import {fireEvent, render} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
test('pagination: pageNum change event', async () => {
const mockFn = jest.fn();
const pageChange = jest.fn();
const {container} = render(
amisRender(
{
type: 'pagination',
layout: 'total,perPage,pager,go',
mode: 'normal',
activePage: 2,
lastPage: 99999,
total: 999,
perPage: 10,
maxButtons: 7,
showPerPage: true,
perPageAvailable: [10, 20, 50, 100],
showPageInput: true,
disabled: false,
id: 'u:1bf323bc4dbd',
onPageChange: pageChange,
onEvent: {
change: {
weight: 0,
actions: [
{
actionType: 'custom',
script: mockFn
}
]
}
}
},
{},
makeEnv({})
)
);
// 当前页码改变
const prev = container.querySelector('.cxd-Pagination-prev')!;
fireEvent.click(prev); // 上一页
await wait(100);
expect(mockFn).toBeCalledTimes(1);
await wait(200);
expect(pageChange).toBeCalled();
expect(pageChange.mock.calls[0]).toEqual([1, 10]);
const next = container.querySelector('.cxd-Pagination-next')!;
fireEvent.click(next); // 下一页
await wait(300);
expect(mockFn).toBeCalledTimes(2);
await wait(200);
expect(pageChange).toBeCalled();
expect(pageChange.mock.calls[1]).toEqual([3, 10]);
const go = container.querySelector('.cxd-Pagination-inputGroup')!;
fireEvent.change(go.querySelector('.cxd-Pagination-inputGroup-input')!, {
target: {value: 9}
});
await wait(400);
fireEvent.click(go.querySelector('.cxd-Pagination-inputGroup-right')!); // 输入后点击go
await wait(500);
expect(mockFn).toBeCalledTimes(3);
await wait(200);
expect(pageChange).toBeCalled();
expect(pageChange.mock.calls[2]).toEqual([9, 10]);
function getPagerItem() {
const pager = container.querySelectorAll(
'.cxd-Pagination > .cxd-Pagination-pager-item'
);
return pager[3];
}
fireEvent.click(getPagerItem()!); // 点击页码切换
await wait(600);
expect(mockFn).toBeCalledTimes(4);
await wait(200);
expect(pageChange).toBeCalled();
expect(pageChange.mock.calls[3]).toEqual([4, 10]);
});
test('pagination: prevent pageNum change event ', async () => {
const mockFn = jest.fn();
const pageChange = jest.fn();
const {container} = render(
amisRender(
{
type: 'pagination',
layout: 'total,perPage,pager,go',
mode: 'normal',
activePage: 2,
lastPage: 99999,
total: 999,
perPage: 10,
maxButtons: 7,
showPerPage: true,
perPageAvailable: [10, 20, 50, 100],
showPageInput: true,
disabled: false,
id: 'u:1bf323bc4dbd',
onPageChange: pageChange,
onEvent: {
change: {
weight: 0,
actions: [
{
actionType: 'custom',
preventDefault: true, // 阻止事件默认行为
script: mockFn
}
]
}
}
},
{},
makeEnv({})
)
);
// 当前页码改变
const prev = container.querySelector('.cxd-Pagination-prev')!;
fireEvent.click(prev); // 上一页
await wait(100);
expect(mockFn).toBeCalledTimes(1);
await wait(200);
expect(pageChange).not.toBeCalled();
const next = container.querySelector('.cxd-Pagination-next')!;
fireEvent.click(next); // 下一页
await wait(300);
expect(mockFn).toBeCalledTimes(2);
await wait(200);
expect(pageChange).not.toBeCalled();
const go = container.querySelector('.cxd-Pagination-inputGroup')!;
fireEvent.change(go.querySelector('.cxd-Pagination-inputGroup-input')!, {
target: {value: 9}
});
await wait(400);
fireEvent.click(go.querySelector('.cxd-Pagination-inputGroup-right')!); // 输入后点击go
await wait(500);
expect(mockFn).toBeCalledTimes(3);
await wait(200);
expect(pageChange).not.toBeCalled();
function getPagerItem() {
const pager = container.querySelectorAll(
'.cxd-Pagination > .cxd-Pagination-pager-item'
);
return pager[3];
}
fireEvent.click(getPagerItem()!); // 点击页码切换
await wait(600);
expect(mockFn).toBeCalledTimes(4);
await wait(200);
expect(pageChange).not.toBeCalled();
});

View File

@@ -0,0 +1,85 @@
import {fireEvent, render} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
test('paginationWrapper: service + crud', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
data: {
items: [
{
label: '110101',
name: '东城区',
sale: 46861
},
{
label: '110102',
name: '西城区',
sale: 44882
}
]
}
}
})
);
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'service',
id: 'u:ff652047d747',
api: {
method: 'get',
url: 'https://yapi.baidu-int.com/mock/42601/amis-chart/chart/sales/data2'
},
body: [
{
type: 'pagination-wrapper',
body: [
{
type: 'crud',
source: '${items}',
columns: [
{
name: 'label',
label: '地区',
type: 'text',
id: 'u:331ab3342710'
},
{
name: 'sale',
label: '销售',
type: 'text',
id: 'u:3dba120eda1d'
}
],
id: 'u:b3c77cb44fc8',
perPageAvailable: [10]
}
],
inputName: 'items',
outputName: 'items',
perPage: 20,
position: 'bottom'
}
]
}
]
},
{},
makeEnv({
fetcher
})
)
);
await wait(200);
const tds = [].slice
.call(container.querySelectorAll('tbody td'))
.map((td: any) => td.textContent);
expect(tds).toEqual(['110101', '46861', '110102', '44882']);
});

View File

@@ -0,0 +1,515 @@
import React = require('react');
import * as renderer from 'react-test-renderer';
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, replaceReactAriaIds, wait} from '../../helper';
test('doAction:service reload', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688871102,
info: ''
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
body: [
{
type: 'input-text',
label: '名字:',
name: 'name',
value: 'amis'
},
{
type: 'input-text',
label: '年龄:',
name: 'age',
value: 18
},
{
type: 'button',
label: '刷新Service数据加载请求',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'service_reload',
actionType: 'reload'
}
]
}
}
}
]
},
{
type: 'service',
api: '/api/mock2/form/initData',
body: [
{
type: 'input-text',
label: '我的名字:',
name: 'name'
},
{
type: 'input-text',
label: '我的年龄:',
name: 'age'
}
],
id: 'service_reload'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(getByText('刷新Service数据加载请求')).toBeInTheDocument();
expect(
container.querySelector('[name="name"][value="Amis Renderer"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/刷新Service数据加载请求/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/mock2/form/initData');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/mock2/form/initData');
expect(
container.querySelector('[name="name"][value="Amis Renderer"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:service reload with data', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
name: 'Amis Renderer',
author: 'fex',
date: 1688871102,
info: ''
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '刷新Service数据加载请求,同时把年龄更新为18',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'service_reload',
actionType: 'reload',
data: {
age: '18'
}
}
]
}
}
},
{
type: 'service',
api: '/api/mock2/form/initData',
body: [
{
type: 'input-text',
label: '我的名字:',
name: 'name'
},
{
type: 'input-text',
label: '我的年龄:',
name: 'age'
}
],
id: 'service_reload'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
getByText('刷新Service数据加载请求,同时把年龄更新为18')
).toBeInTheDocument();
expect(
container.querySelector('[name="name"][value="Amis Renderer"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/刷新Service数据加载请求,同时把年龄更新为18/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/mock2/form/initData');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/mock2/form/initData');
expect(
container.querySelector('[name="name"][value="Amis Renderer"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value="18"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:service(schemaApi) reload', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
controls: [
{
type: 'input-text',
label: '我的名字:',
name: 'name'
},
{
type: 'input-text',
label: '我的年龄:',
name: 'age'
}
]
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '刷新Service数据加载请求',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'service_reload',
actionType: 'reload'
}
]
}
}
},
{
type: 'service',
schemaApi: '/api/schemaApi',
id: 'service_reload'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(getByText('刷新Service数据加载请求')).toBeInTheDocument();
expect(
container.querySelector('[name="name"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/刷新Service数据加载请求/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/schemaApi?_replace=1');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/schemaApi?_replace=1');
expect(
container.querySelector('[name="name"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:service(schemaApi) reload with data', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
controls: [
{
type: 'input-text',
label: '我的名字:',
name: 'name'
},
{
type: 'input-text',
label: '我的年龄:',
name: 'age'
}
]
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '刷新Service数据加载请求,同时把年龄更新为18',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'service_reload',
actionType: 'reload',
data: {
age: '18'
}
}
]
}
}
},
{
type: 'service',
schemaApi: '/api/schemaApi',
id: 'service_reload'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
getByText('刷新Service数据加载请求,同时把年龄更新为18')
).toBeInTheDocument();
expect(
container.querySelector('[name="name"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/刷新Service数据加载请求,同时把年龄更新为18/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/schemaApi?_replace=1');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/schemaApi?_replace=1');
expect(
container.querySelector('[name="name"][value=""]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value="18"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('doAction:service(schemaApi+data) reload with data', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
data: {
name: 'amis',
age: 20
},
controls: [
{
type: 'input-text',
label: '我的名字:',
name: 'name'
},
{
type: 'input-text',
label: '我的年龄:',
name: 'age'
}
]
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'button',
label: '刷新Service数据加载请求,同时把年龄更新为18',
level: 'primary',
className: 'mb-2',
onEvent: {
click: {
actions: [
{
componentId: 'service_reload',
actionType: 'reload',
data: {
age: '18'
}
}
]
}
}
},
{
type: 'service',
schemaApi: '/api/schemaApi',
id: 'service_reload'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
getByText('刷新Service数据加载请求,同时把年龄更新为18')
).toBeInTheDocument();
expect(
container.querySelector('[name="name"][value="amis"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value="20"]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/刷新Service数据加载请求,同时把年龄更新为18/));
await waitFor(() => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(fetcher.mock.calls[0][0].url).toEqual('/api/schemaApi?_replace=1');
expect(fetcher.mock.calls[1][0].url).toEqual('/api/schemaApi?_replace=1');
expect(
container.querySelector('[name="name"][value="amis"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="age"][value="18"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,64 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('EventAction:toast', async () => {
const notify = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
msg: '我是全局警告消息,可以配置不同类型和弹出位置'
},
body: [
{
type: 'button',
label: 'toast',
level: 'warning',
className: 'mr-2 mb-2',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'warning',
msg: '${msg}~',
position: 'top-right',
closeButton: true,
showIcon: true,
timeout: 5000
}
}
]
}
}
}
]
},
{},
makeEnv({
notify
})
)
);
fireEvent.click(getByText('toast'));
await waitFor(() => {
expect(notify).toHaveBeenCalled();
});
expect(notify.mock.calls[0][0]).toEqual('warning');
expect(notify.mock.calls[0][1]).toEqual(
'我是全局警告消息,可以配置不同类型和弹出位置~'
);
expect(notify.mock.calls[0][2]).toEqual({
msgType: 'warning',
msg: '我是全局警告消息,可以配置不同类型和弹出位置~',
position: 'top-right',
closeButton: true,
showIcon: true,
timeout: 5000
});
});

View File

@@ -0,0 +1,105 @@
import {fireEvent, render, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('EventAction:url & link', async () => {
const jumpTo = jest.fn();
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
myname: 'lvxj',
myjon: 'player'
},
body: [
{
type: 'button',
label: '跳转',
level: 'primary',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'url',
args: {
url: 'http://www.baidu.com',
blank: true,
params: {
name: 'jack',
jon: '${myjon}'
}
},
data: {
name: '${myname}',
age: 18
}
}
]
}
}
},
{
type: 'button',
label: '打开',
level: 'primary',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'link',
args: {
link: './expression',
targetType: 'page',
params: {
name: 'jack',
jon: '${myjon}'
}
},
data: {
name: '${myname}',
age: 18
}
}
]
}
}
}
]
},
{},
makeEnv({
jumpTo
})
)
);
fireEvent.click(getByText('跳转'));
fireEvent.click(getByText('打开'));
await waitFor(() => {
expect(jumpTo).toHaveBeenCalled();
});
expect(jumpTo.mock.calls[0][0]).toEqual(
'http://www.baidu.com?name=lvxj&jon=player&age=18'
);
expect(jumpTo.mock.calls[0][1]).toEqual({
actionType: 'url',
type: 'button',
url: 'http://www.baidu.com',
blank: true,
params: {
name: 'jack',
jon: 'player'
}
});
expect(jumpTo.mock.calls[0][2]).toEqual({
age: 18,
name: 'lvxj'
});
expect(jumpTo.mock.calls[1][0]).toEqual(
'./expression?name=lvxj&jon=player&age=18'
);
});

View File

@@ -0,0 +1,151 @@
import {waitFor} from '@testing-library/react';
import {RenderOptions} from '../src';
import '../src';
// jest.useFakeTimers 会修改 global 的 setTimeout 所以需要把原始的记录下来。
const timerFn = (global as any).originSetTimeout || setTimeout;
export function wait(duration: number, fnOrUseWaitFor?: Function | boolean) {
const useWaitFor = fnOrUseWaitFor !== false;
const fn = (
typeof fnOrUseWaitFor === 'function' ? fnOrUseWaitFor : undefined
) as Function;
return useWaitFor
? waitFor(
() =>
new Promise<void>(resolve => {
timerFn(() => {
fn && fn();
resolve();
}, duration);
}),
{
timeout: duration + 100
}
)
: new Promise<void>(resolve => {
timerFn(() => {
fn && fn();
resolve();
}, duration);
});
}
export function makeEnv(env?: Partial<RenderOptions>): RenderOptions {
return {
session: 'test-case',
isCancel: () => false,
notify: (msg: string) => null,
jumpTo: (to: string) => console.info('Now should jump to ' + to),
alert: msg => console.info(`Alert: ${msg}`),
...env
};
}
export const createMockMediaMatcher =
(matchesOrMapOfMatches: any) => (qs: any) => ({
matches:
typeof matchesOrMapOfMatches === 'object'
? matchesOrMapOfMatches[qs]
: matchesOrMapOfMatches,
media: '',
addListener: () => {},
addEventListener: () => {},
removeEventListener: () => {},
onchange: () => {},
removeListener: () => {},
dispatchEvent: () => {
return true;
}
});
export function formatStyleObject(style: string | null, px2number = true) {
if (!style) {
return {};
}
// 去除注释 /* xx */
style = style.replace(/\/\*[^(\*\/)]*\*\//g, '');
const res: any = {};
style.split(';').forEach((item: string) => {
if (!item || !String(item).includes(':')) return;
const [key, value] = item.split(':');
res[String(key).trim()] =
px2number && value.endsWith('px')
? Number(String(value).replace(/px$/, ''))
: String(value).trim();
});
return res;
}
/**
* This function searches for the every react-aria SSR ids in a given HTMLElement node and replace every attribute values with a static id
*
* This can be usefull when you're trying to generate a snapshot of components using react-aria under the hood
*
* @ex :
* ```
* const { container } = render(<Component />);
*
* replaceReactAriaIds(container);
* ```
*
* @param container The HTMLElement node to search for SSR ids
*/
export function replaceReactAriaIds(container: HTMLElement) {
const selectors = ['aria-labelledby'];
const ariaSelector = (el: string) => `[${el}]`;
const regexp = /downshift\-\d+-label/g;
container
.querySelectorAll(selectors.map(ariaSelector).join(', '))
.forEach(el => {
selectors.forEach(selector => {
const attr = el.getAttribute(selector);
if (attr?.match(regexp)) {
el.removeAttribute(selector);
}
});
});
container.querySelectorAll('[data-id]').forEach(el => {
const val = el.getAttribute('data-id');
if (typeof val === 'string' && /^[a-z0-9]{12}$/.test(val)) {
el.removeAttribute('data-id');
}
});
}
// Mock IntersectionObserver
class IntersectionObserver {
observe = jest.fn();
disconnect = jest.fn();
unobserve = jest.fn();
}
Object.defineProperty(window, 'IntersectionObserver', {
writable: true,
configurable: true,
value: IntersectionObserver
});
Object.defineProperty(global, 'IntersectionObserver', {
writable: true,
configurable: true,
value: IntersectionObserver
});
(global as any).document.createRange = () => ({
selectNodeContents: jest.fn(),
getBoundingClientRect: jest.fn(() => ({
width: 500
})),
getClientRects: jest.fn(() => []),
setStart: jest.fn(),
setEnd: jest.fn()
});

View File

@@ -0,0 +1,32 @@
const originalWarn = console.warn.bind(console.warn);
const originalGroupCollapsed = console.warn.bind(console.groupCollapsed);
const originalGroupEnd = console.warn.bind(console.groupEnd);
const originalDebug = console.warn.bind(console.debug);
require('@testing-library/jest-dom');
require('moment-timezone');
const moment = require('moment');
moment.tz.setDefault('Asia/Shanghai');
global.beforeAll(() => {
console.warn =
console.groupCollapsed =
console.groupEnd =
console.debug =
msg => {
// warning 先关了,实在太吵。
// const str = msg.toString();
// if (
// str.includes('componentWillMount') ||
// str.includes('componentWillReceiveProps')
// ) {
// return;
// }
// originalWarn(msg);
};
});
global.afterAll(() => {
console.warn = originalWarn;
console.groupCollapsed = originalGroupCollapsed;
console.groupEnd = originalGroupEnd;
console.debug = originalDebug;
});

View File

@@ -0,0 +1,82 @@
export default [
{
engine: 'Trident',
browser: 'Internet Explorer 4.0',
platform: 'Win 95+',
version: '4',
grade: 'A',
__id: 1
},
{
engine: 'Trident',
browser: 'Internet Explorer 4.2',
platform: 'Win 95+',
version: '4',
grade: 'B',
__id: 2
},
{
engine: 'Trident',
browser: 'AOL browser (AOL desktop)',
platform: 'Win 95+',
version: '4',
grade: 'C',
__id: 3
},
{
engine: 'Trident',
browser: 'AOL browser (AOL desktop)',
platform: 'Win 98',
version: '3',
grade: 'A',
__id: 4
},
{
engine: 'Trident',
browser: 'AOL browser (AOL desktop)',
platform: 'Win 98',
version: '4',
grade: 'A',
__id: 5
},
{
engine: 'Gecko',
browser: 'Firefox 1.0',
platform: 'Win 98+ / OSX.2+',
version: '4',
grade: 'A',
__id: 6
},
{
engine: 'Gecko',
browser: 'Firefox 1.0',
platform: 'Win 98+ / OSX.2+',
version: '5',
grade: 'A',
__id: 7
},
{
engine: 'Gecko',
browser: 'Firefox 2.0',
platform: 'Win 98+ / OSX.2+',
version: '5',
grade: 'B',
__id: 8
},
{
engine: 'Gecko',
browser: 'Firefox 2.0',
platform: 'Win 98+ / OSX.2+',
version: '5',
grade: 'C',
__id: 9
},
{
engine: 'Gecko',
browser: 'Firefox 2.0',
platform: 'Win 98+ / OSX.2+',
version: '5',
grade: 'D',
__id: 10
}
];

View File

@@ -0,0 +1,22 @@
import React = require('react');
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:amisRender test', () => {
const {container} = render(
amisRender(
{
type: 'amis',
value: {
type: 'tpl',
tpl: 'hello world'
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,463 @@
/**
* 组件名称:Action 行为按钮
*
* 单测内容:
1. 点击切换
*/
import React from 'react';
import Action from '../../src/renderers/Action';
import * as renderer from 'react-test-renderer';
import {
render,
fireEvent,
cleanup,
screen,
waitFor,
within
} from '@testing-library/react';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
import '../../src';
import hotkeys from 'hotkeys-js';
afterEach(cleanup);
// 1. levels 样式
test('Renderers:Action all levels', () => {
const levels = [
'link',
'primary',
'secondary',
'info',
'success',
'warning',
'danger',
'light',
'dark',
'default'
];
const {container} = render(
amisRender(
{
type: 'page',
body: [
levels.map(item => ({
type: 'button',
level: item,
label: `按钮 ${item}`
})),
{
type: 'divider'
},
levels.map(item => ({
type: 'button',
level: item,
disabled: true,
label: `按钮${item}`
}))
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
// 2. Action 组件尺寸
test('Renderers:Action display size[xs, sm, md, lg]', () => {
const component = renderer.create(<Action size="xs" />);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(<Action size="sm" />);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(<Action size="md" />);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(<Action size="lg" />);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
// 3. MenuItem 下激活与禁用状态
test('Renderers:Action MenuItem changes class when actived & disabled', () => {
const component = renderer.create(
<Action isMenuItem className="a" label="123" />
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(<Action isMenuItem className="a" label="233" active />);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(
<Action isMenuItem className="a" label="233" active disabled />
);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
// 4. MenuItem 下设置图标
test('Renderers:Action MenuItem display icon', () => {
const component = renderer.create(
<Action isMenuItem className="a" label="123" />
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(
<Action isMenuItem className="a" label="123" icon="fa fa-cloud" />
);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
// 5. actionType 为 link 时的 类
test('Renderers:Action [actionType = "link"] show active class', () => {
const isCurrentUrl = (link: string) => link === 'b';
const component = renderer.create(
<Action
actionType="link"
link="a"
className="a"
label="123"
isCurrentUrl={isCurrentUrl}
/>
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(
<Action
actionType="link"
link="b"
className="a"
label="123"
isCurrentUrl={isCurrentUrl}
/>
);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
// 6. 自定义激活态下的类
test('Renderers:Action custom activeClass', () => {
const component = renderer.create(
<Action className="a" label="123" activeClassName="custom-active" />
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
component.update(
<Action className="a" label="123" activeClassName="custom-active" active />
);
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
// 7. onAction 方法调用
test('Renderers:Action onAction called?', () => {
const onAction = jest.fn();
const {getByText} = render(
<Action className="a" label="123" onAction={onAction}></Action>
);
fireEvent.click(getByText(/123/));
expect(onAction).toHaveBeenCalled();
});
// 8. disabled 下 onAction 调用情况
test('Renderers:Action disabled onAction called?', () => {
const onAction = jest.fn();
const {getByText} = render(
<Action disabled className="a" label="123" onAction={onAction}></Action>
);
fireEvent.click(getByText(/123/));
expect(onAction).not.toHaveBeenCalled();
});
// 9. onClick 与 onAction 共存时,仅调用 onClick
test('Renderers:Action onClick cancel onAction?', () => {
const onAction = jest.fn();
const onClick = jest.fn(e => e.preventDefault());
const {getByText} = render(
<Action
isMenuItem
className="a"
label="123"
onClick={onClick}
onAction={onAction}
></Action>
);
fireEvent.click(getByText(/123/));
expect(onClick).toHaveBeenCalled();
expect(onAction).not.toHaveBeenCalled();
});
// 10. actionType 为 download
test('Renderers:Action download shortcut', () => {
const component = renderer.create(
<Action actionType="download" link="a" label="123" />
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
// 11. countDown 倒计时
test('Renderers:Action countDown', async () => {
const {container} = render(
amisRender(
{
label: '发送验证码',
type: 'button',
className: 'countDown',
countDown: 1
},
{},
makeEnv({})
)
);
let button = container.querySelector('button');
fireEvent.click(button as HTMLButtonElement);
await waitFor(() => {
expect(container.querySelector('button')).not.toBeInTheDocument();
});
});
// 12. tooltip
test('Renderers:Action tooltip', async () => {
const {container, getByText, findByText} = render(
amisRender(
{
type: 'page',
body: [
{
label: 'top',
type: 'action',
tooltip: 'topTooltip',
tooltipPlacement: 'top'
},
{
label: 'bottom',
type: 'action',
tooltip: 'bottomTooltip',
tooltipPlacement: 'bottom'
},
{
label: 'left',
type: 'action',
tooltip: 'leftTooltip',
tooltipPlacement: 'left'
},
{
label: 'right',
type: 'action',
tooltip: 'rightTooltip',
tooltipPlacement: 'right'
}
]
},
{},
makeEnv({})
)
);
fireEvent.mouseOver(getByText(/top/));
await findByText('topTooltip');
expect(container).toMatchSnapshot();
});
// 13. feedback
// test('Renderers:Action click feedback', async () => {
// const fetcher = jest.fn().mockImplementation(() =>
// Promise.resolve({
// data: {
// status: 0,
// msg: 'ok',
// data: ''
// }
// })
// );
// const {getByText, container, baseElement}: any = render(
// amisRender(
// {
// type: 'page',
// body: {
// type: 'button',
// label: 'Feedback',
// actionType: 'ajax',
// api: '/api/mock2/form/initData?waitSeconds=0',
// feedback: {
// title: '操作成功',
// body: '${id} 已操作成功'
// }
// }
// },
// {},
// makeEnv({
// session: 'test-case-action',
// fetcher
// })
// )
// );
// fireEvent.click(container.querySelector('.cxd-Button'));
// wait(2000);
// expect(fetcher).toBeCalled();
// expect(baseElement).toMatchSnapshot();
// expect(
// await within(baseElement.querySelector('.cxd-Modal-content')!).getByText(
// 'xxx 已操作成功'
// )!
// ).toBeInTheDocument();
// });
// 14. confirmText
test('Renderers:Action with confirmText & actionType ajax', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: ''
}
})
);
const {getByText, container, baseElement}: any = render(
amisRender(
{
type: 'page',
body: {
label: 'ajax请求',
type: 'button',
actionType: 'ajax',
confirmText: '确认要发出这个请求?',
api: '/api/mock2/form/saveForm'
}
},
{},
makeEnv({
session: 'test-case-action-no',
fetcher
})
)
);
fireEvent.click(container.querySelector('.cxd-Button'));
await wait(500);
expect(baseElement).toMatchSnapshot();
expect(baseElement.querySelector('.cxd-Modal-content')!).toHaveTextContent(
'确认要发出这个请求?'
);
fireEvent.click(getByText('取消'));
await wait(500);
expect(fetcher).not.toBeCalled();
fireEvent.click(container.querySelector('.cxd-Button'));
await wait(500);
fireEvent.click(getByText('确认'));
await wait(200);
// fetcher 该被执行了
expect(fetcher).toBeCalled();
});
// 15.Action 作为容器组件
test('Renderers:Action as container', async () => {
const notify = jest.fn();
const {getByText, container, baseElement}: any = render(
amisRender(
{
type: 'action',
body: [
{
type: 'color',
value: '#108cee'
}
],
actionType: 'toast',
toast: {
items: [
{
body: '点击了颜色'
}
]
}
},
{},
makeEnv({
notify,
session: 'test-action-3'
})
)
);
const color = container.querySelector('.cxd-ColorField');
expect(color).toBeInTheDocument();
fireEvent.click(color);
await wait(200);
expect(notify).toBeCalled();
expect(container).toMatchSnapshot();
});
// 16. disabledTip
test('Renderers:Action with disabledTip', async () => {
const {container, getByText, findByText} = render(
amisRender(
{
type: 'page',
body: [
{
label: '弹框',
type: 'button',
actionType: 'link',
disabled: true,
link: '../index',
disabledTip: '禁用了'
}
]
},
{},
makeEnv({})
)
);
fireEvent.mouseEnter(getByText('弹框')!);
await wait(200);
expect(container).toMatchSnapshot();
expect(getByText('禁用了')).toBeInTheDocument();
});

View File

@@ -0,0 +1,242 @@
/**
* 组件名称:Alert 提示
*
* 单测内容:
* 1. 基础使用
* 2. 获取上下文变量
* 3. 级别 level
* 4. title & showIcon & icon & iconClassName
* 5. showCloseButton & closeButtonClassName
*/
import React from 'react';
import {fireEvent, render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:alert', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'alert',
level: 'success',
body: [
{
type: 'tpl',
tpl: '提示内容'
}
]
}
},
{},
makeEnv({})
)
);
expect(container.querySelector('.cxd-Alert')).toHaveTextContent('提示内容');
expect(container).toMatchSnapshot();
});
test('Renderer:alert var', () => {
const {container} = render(
amisRender({
type: 'page',
data: {
level: 'success',
icon: 'copy',
showIcon: true,
bodyTpl: '百度一下,你就知道'
},
body: {
type: 'alert',
level: '${level}',
icon: '${icon}',
showIcon: '${showIcon}',
body: '${bodyTpl}'
}
})
);
expect(container).toMatchSnapshot();
expect(container.querySelector('.cxd-Alert')).toHaveClass(
'cxd-Alert--success'
);
expect(container.querySelector('.cxd-Alert-icon icon-mock')).toHaveAttribute(
'classname',
'icon icon-copy'
);
expect(container.querySelector('.cxd-Alert-content')).toHaveTextContent(
'百度一下,你就知道'
);
});
test('Renderer:alert with level', () => {
const {container} = render(
amisRender({
type: 'page',
body: [
{
type: 'alert',
body: '提示类文案',
level: 'info'
},
{
type: 'alert',
body: '成功类文案',
level: 'success'
},
{
type: 'alert',
body: '警告类文案',
level: 'warning'
},
{
type: 'alert',
body: '危险类文案',
level: 'danger'
}
]
})
);
expect(container).toMatchSnapshot();
const alerts = container.querySelectorAll('.cxd-Alert');
expect(alerts!.length).toBe(4);
expect(alerts[0]).toHaveClass('cxd-Alert--info');
expect(alerts[1]).toHaveClass('cxd-Alert--success');
expect(alerts[2]).toHaveClass('cxd-Alert--warning');
expect(alerts[3]).toHaveClass('cxd-Alert--danger');
});
test('Renderer:alert with title & showIcon & icon & iconClassName', () => {
const renderAmis = (options: any = {}) =>
amisRender({
type: 'page',
body: {
type: 'alert',
body: '提示类文案',
level: 'info',
...options
}
});
const {container, rerender} = render(renderAmis());
expect(container.querySelector('.cxd-Alert-title')!).not.toBeInTheDocument();
rerender(
renderAmis({
title: '提示类文案'
})
);
expect(container.querySelector('.cxd-Alert-title')!).toBeInTheDocument();
expect(container.querySelector('.cxd-Alert-title')!).toHaveTextContent(
'提示类文案'
);
expect(container.querySelector('.cxd-Alert-icon')).not.toBeInTheDocument();
rerender(
renderAmis({
title: '提示类文案',
showIcon: true
})
);
expect(container.querySelector('.cxd-Alert-icon')).toBeInTheDocument();
expect(container.querySelector('.cxd-Alert-icon icon-mock')).toHaveAttribute(
'classname',
'icon icon-alert-info'
);
rerender(
renderAmis({
title: '提示类文案',
showIcon: true,
icon: 'star',
iconClassName: 'starClass'
})
);
expect(container.querySelector('.cxd-Alert-icon icon-mock')).toHaveAttribute(
'classname',
'icon icon-star'
);
expect(container.querySelector('.cxd-Alert-icon')).toHaveClass('starClass');
expect(container).toMatchSnapshot();
});
test('Renderer:alert with showCloseButton & closeButtonClassName', () => {
const {container, rerender} = render(
amisRender({
type: 'page',
body: {
type: 'alert',
body: '提示信息',
level: 'info'
}
})
);
expect(
container.querySelector('.cxd-Alert .cxd-Alert-close')
).not.toBeInTheDocument();
rerender(
amisRender({
type: 'page',
body: {
type: 'alert',
body: '提示信息',
level: 'info',
showCloseButton: true,
closeButtonClassName: 'classNameForClose'
}
})
);
const closeBth = container.querySelector('.cxd-Alert .cxd-Alert-close')!;
expect(closeBth).toBeInTheDocument();
expect(closeBth).toHaveClass('classNameForClose');
expect(container).toMatchSnapshot();
fireEvent.click(closeBth);
expect(container.querySelector('.cxd-Alert')).not.toBeInTheDocument();
});
test('Renderer:alert with actions', () => {
const {container} = render(amisRender({
"type": "alert",
"level": "success",
"className": "mb-3",
"showIcon": true,
"showCloseButton": true,
"title": "标题",
"body": "创建成功",
"actions": [
{
"type": "button",
"label": "查看详情",
"size": "xs",
"level": "link"
}
]
}, {}, makeEnv({})));
const alert = container.querySelector('.cxd-Alert');
expect(alert).toBeInTheDocument();
const actions = container.querySelector('.cxd-Alert-actions')!;
expect(actions).toBeInTheDocument();
expect(actions.childNodes.length).toEqual(1);
});

View File

@@ -0,0 +1,342 @@
/**
* 组件名称:AnchorNav 锚点导航
* 单测内容:
* 1. 基本使用
* 2. 水平模式
* 3. 默认定位到某个区域
*/
import React from 'react';
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
const defaultLinks = [
{
title: '基本信息',
body: [
{
type: 'form',
title: '基本信息',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'email',
type: 'input-email',
label: '邮箱:'
}
]
}
]
},
{
title: '工作信息',
body: [
{
type: 'form',
title: '工作信息',
body: [
{
type: 'input-text',
name: 'cname',
label: '公司名称:'
},
{
name: 'caddress',
type: 'input-text',
label: '公司地址:'
}
]
}
]
},
{
title: '兴趣爱好',
body: [
{
type: 'form',
title: '兴趣爱好',
body: [
{
type: 'input-text',
name: 'interest1',
label: '兴趣爱好1:'
},
{
name: 'interest2',
type: 'input-text',
label: '兴趣爱好2:'
},
{
name: 'interest3',
type: 'input-text',
label: '兴趣爱好3:'
},
{
name: 'interest4',
type: 'input-text',
label: '兴趣爱好4:'
},
{
name: 'interest5',
type: 'input-text',
label: '兴趣爱好5:'
},
{
name: 'interest6',
type: 'input-text',
label: '兴趣爱好6:'
}
]
}
]
}
];
// 1. 基本使用
test('Renderer:anchorNav', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'anchor-nav',
links: defaultLinks,
linkClassName: 'linksWrap',
sectionClassName: 'sectionsWrap'
}
},
{},
makeEnv({})
)
);
expect(container.querySelector('.cxd-AnchorNav-link-wrap')).toHaveClass(
'linksWrap'
);
expect(container.querySelector('.cxd-AnchorNav-section-wrap')).toHaveClass(
'sectionsWrap'
);
expect(container).toMatchSnapshot();
});
// 2. 水平模式
test('Renderer:anchorNav with horizontal', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'anchor-nav',
direction: 'horizontal',
links: [
{
title: '基本信息',
body: [
{
type: 'form',
title: '基本信息',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'email',
type: 'input-email',
label: '邮箱:'
}
]
}
]
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
// 3.默认定位到某个区域
test('Renderer:anchorNav with active by index', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'anchor-nav',
className: 'one',
active: 2,
links: defaultLinks
}
]
},
{},
makeEnv({})
)
);
await wait(500);
expect(
container.querySelector('.one .cxd-AnchorNav-link.is-active')
).toHaveTextContent('兴趣爱好');
});
test('Renderer:anchorNav with active by href', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'anchor-nav',
className: 'two',
active: 'work',
links: defaultLinks.map((item, index) => ({
...item,
href: ['base', 'work', 'interest'][index]
}))
}
]
},
{},
makeEnv({})
)
);
await wait(500);
expect(
container.querySelector('.two .cxd-AnchorNav-link.is-active')
).toHaveTextContent('工作信息');
});
// 4. 子菜单
test('Renderer:anchorNav with children', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'anchor-nav',
direction: 'horizontal',
links: [
{
title: '基本信息',
body: [
{
type: 'form',
title: '基本信息',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名:'
},
{
name: 'email',
type: 'input-email',
label: '邮箱:'
}
]
}
],
children: [
{
title: '基本信息1-1',
body: [
{
type: 'form',
title: '基本信息1-1',
body: [
{
type: 'input-text',
name: 'cname1',
label: 'cname1'
},
{
name: 'caddress1',
type: 'input-text',
label: 'caddress1'
}
]
}
]
},
{
title: '基本信息1-2',
body: [
{
type: 'form',
title: '基本信息1-2',
body: [
{
type: 'input-text',
name: 'cname2',
label: 'cname2'
},
{
name: 'caddress2',
type: 'input-text',
label: 'caddress2'
}
]
}
]
}
]
},
{
title: '工作信息',
body: [
{
type: 'form',
title: '工作信息',
body: [
{
type: 'input-text',
name: 'cname',
label: '公司名称:'
},
{
name: 'caddress',
type: 'input-text',
label: '公司地址:'
}
]
}
]
}
]
}
},
{},
makeEnv({})
)
);
await wait(500);
expect(
container.querySelector('.cxd-AnchorNav-link-child')
).toHaveTextContent('基本信息1-1');
expect(
container.querySelector('.cxd-AnchorNav-link.is-active')
).toHaveTextContent('基本信息');
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,104 @@
import React from 'react';
import Action from '../../src/renderers/Action';
import * as renderer from 'react-test-renderer';
import {
render,
fireEvent,
cleanup,
screen,
waitFor,
within
} from '@testing-library/react';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
import '../../src';
afterEach(cleanup);
// 关联 issue https://github.com/baidu/amis/issues/9564
test('Renderers:App locale', async () => {
const fetcher = jest.fn().mockImplementation((api, options) => {
if (api.url.startsWith('/pageList')) {
return Promise.resolve({
status: 200,
data: {
status: 0,
msg: '',
data: {
pages: [
{
children: [
{
'label': 'Home',
'icon': 'fa fa-home',
'url': '/admin/page/home',
'schemaApi': '/pageDetail',
'isDefaultPage': true,
'sort': 100,
'zh-CN': {
label: '首页'
}
}
]
}
]
}
}
});
} else if (api.url.startsWith('/pageDetail')) {
return Promise.resolve({
status: 200,
data: {
type: 'page',
body: [
{
'type': 'input-text',
'name': 'a',
'label': 'dev',
'content': 'False',
'zh-CN': {
label: '开发环境'
}
}
]
}
});
}
return Promise.resolve({
status: 200,
data: {
status: 404,
msg: 'notFound'
}
});
});
const {container, getByText} = render(
amisRender(
{
type: 'app',
api: {
method: 'get',
url: '/pageList'
}
},
{
locale: 'zh-CN'
},
makeEnv({
fetcher
})
)
);
await wait(500);
const link = container.querySelector('nav li span');
expect(link).toBeInTheDocument();
expect(link!.textContent).toBe('首页');
const inputLabel = container.querySelector('.cxd-Form-label');
expect(inputLabel).toBeInTheDocument();
expect(inputLabel!.textContent).toBe('开发环境');
});

View File

@@ -0,0 +1,55 @@
import {render} from '@testing-library/react';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
let times = 0;
beforeAll(() => {
// jsdom not implemented: HTMLMediaElement.prototype.load
// here: https://github.com/jsdom/jsdom/issues/1515
Object.defineProperty(global.window.HTMLMediaElement.prototype, 'load', {
get() {
return () => {
times++;
};
}
});
});
afterEach(() => {
times = 0;
});
test('Renderer:audio', () => {
const {container} = render(
amisRender(
{
type: 'audio',
src: '${url}'
},
{
data: {
url: 'https://example.com/music.mp3'
}
},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('should not call load method at first render phase', () => {
render(
amisRender(
{
type: 'audio',
src: 'https://example.com/music.mp3'
},
{},
makeEnv({})
)
);
expect(times).toBe(0);
});

View File

@@ -0,0 +1,229 @@
import React = require('react');
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:avatar test', () => {
const {container} = render(
amisRender(
{
type: 'avatar',
text: 'AM'
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:avatar icon', () => {
const {container} = render(
amisRender(
{
type: 'avatar',
icon: 'fa fa-user'
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:avatar var', () => {
const {container} = render(
amisRender(
{
data: {
myAvatar: 'https://suda.cdn.bcebos.com/images/amis/ai-fake-face.jpg'
},
type: 'page',
body: [
{
type: 'avatar',
icon: 'fa fa-user',
src: '$myAvatar'
},
{
type: 'avatar',
icon: 'fa fa-user',
src: '$other'
},
{
type: 'avatar',
src: '$other',
icon: 'fa fa-user',
text: 'avatar'
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:avatar shape', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'avatar',
shape: 'square',
text: 'AM'
},
{
type: 'avatar',
shape: 'rounded',
text: 'AM',
style: {
marginLeft: '10px'
}
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:avatar size', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'avatar',
size: 'large',
icon: 'fa fa-user'
},
{
type: 'avatar',
size: 'default',
icon: 'fa fa-user'
},
{
type: 'avatar',
size: 'small',
icon: 'fa fa-user'
},
{
type: 'avatar',
size: 60,
src: 'https://suda.cdn.bcebos.com/images/amis/ai-fake-face.jpg'
},
{
type: 'avatar',
src: 'https://suda.cdn.bcebos.com/images/amis/ai-fake-face.jpg'
},
{
type: 'avatar',
size: 20,
src: 'https://suda.cdn.bcebos.com/images/amis/ai-fake-face.jpg'
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:avatar gap', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'avatar',
text: 'ejson',
gap: 2
},
{
type: 'avatar',
text: 'ejson',
gap: 7
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:avatar fit', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'avatar',
fit: 'cover',
src: 'https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg'
},
{
type: 'avatar',
fit: 'fill',
src: 'https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg'
},
{
type: 'avatar',
fit: 'contain',
src: 'https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg'
},
{
type: 'avatar',
fit: 'none',
src: 'https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg'
},
{
type: 'avatar',
fit: 'scale-down',
src: 'https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg'
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:avatar style', () => {
const {container} = render(
amisRender(
{
type: 'avatar',
text: 'AM',
style: {
background: '#DB3E35',
color: '#FFFFFF'
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,27 @@
import React = require('react');
import {render, fireEvent, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
import 'jest-canvas-mock';
test('Renderer:bar-code', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'barcode',
value: 'amis'
}
},
{},
makeEnv({})
)
);
await waitFor(() =>
expect(container.querySelector('.cxd-BarCode')).toBeInTheDocument()
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,217 @@
import React = require('react');
import {fireEvent, render, screen} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
import * as renderer from 'react-test-renderer';
test('Renderer:breadcrumb', () => {
const {container} = render(
amisRender(
{
type: 'breadcrumb',
items: [
{
label: '首页',
href: 'https://baidu.gitee.com/',
icon: 'fa fa-home'
},
{
label: '上级页面'
},
{
label: '<b>当前页面</b>'
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:breadcrumb var', () => {
const {container} = render(
amisRender(
{
type: 'page',
data: {
breadcrumb: [
{
label: '首页',
href: 'https://baidu.gitee.com/'
},
{
label: '上级页面'
},
{
label: '<b>当前页面</b>'
}
]
},
body: {
type: 'breadcrumb',
source: '${breadcrumb}'
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:breadcrumb separator', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'breadcrumb',
separator: '>',
separatorClassName: 'text-black',
items: [
{
label: '首页',
href: 'https://baidu.gitee.com/',
icon: 'fa fa-home'
},
{
label: '上级页面'
},
{
label: '<b>当前页面</b>'
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:breadcrumb dropdown', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'breadcrumb',
items: [
{
label: '首页',
href: 'https://baidu.gitee.com/',
icon: 'fa fa-home'
},
{
label: '上级页面',
dropdown: [
{
label: '选项一',
href: 'https://baidu.gitee.com/'
},
{
label: '选项二'
}
]
},
{
label: '<b>当前页面</b>'
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:breadcrumb tooltip labelMaxLength', () => {
const schema = {
type: 'page',
body: {
type: 'breadcrumb',
separator: '>',
separatorClassName: 'text-black',
labelMaxLength: 16,
tooltipPosition: 'bottom',
items: [
{
href: 'https://baidu.gitee.com/',
icon: 'fa fa-home'
},
{
label: '上级页面上级页面上级页面上级页面上级页面'
},
{
label: '当前页面'
}
]
}
};
const component = renderer.create(amisRender(schema, {}, makeEnv({})));
expect(component.toJSON()).toMatchSnapshot();
schema.body.tooltipPosition = 'top';
component.update(amisRender(schema, {}, makeEnv({})));
expect(component.toJSON()).toMatchSnapshot();
schema.body.tooltipPosition = 'left';
component.update(amisRender(schema, {}, makeEnv({})));
expect(component.toJSON()).toMatchSnapshot();
schema.body.tooltipPosition = 'right';
component.update(amisRender(schema, {}, makeEnv({})));
expect(component.toJSON()).toMatchSnapshot();
});
test('Renderer:breadcrumb className', () => {
const {container} = render(
amisRender(
{
type: 'breadcrumb',
dropdownClassName: 'dropdownClassName',
dropdownItemClassName: 'dropdownItemClassName',
itemClassName: 'itemClassName',
className: 'className',
items: [
{
label: '首页',
href: 'https://baidu.gitee.com/',
icon: 'fa fa-home'
},
{
label: '上级页面',
dropdown: [
{
label: '选项一',
href: 'https://baidu.gitee.com/'
},
{
label: '选项二'
}
]
},
{
label: '<b>当前页面</b>'
}
]
},
{},
makeEnv({})
)
);
fireEvent.click(container.querySelector('.cxd-Breadcrumb-item-caret')!);
expect(!container.querySelector('.dropdownClassName')).toBeFalsy();
expect(!container.querySelector('.dropdownItemClassName')).toBeFalsy();
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,32 @@
import React = require('react');
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:button-toolbar', async () => {
const {container} = render(
amisRender(
{
type: 'button-toolbar',
name: 'button-toolbar',
label: 'button-toolbar',
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
],
className: 'show'
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,70 @@
/*
* @Author: ZhangBaiSen
* @since: 2023-06-02 15:46:01
* @LastEditors: ZhangBaiSen
* @LastEditTime: 2023-06-02 15:46:54
* @desc:290057637@qq.com
* @文件相对于项目的路径: /fork-amis/packages/amis/__tests__/renderers/CRUD2.test.tsx
*/
import {
cleanup,
fireEvent,
render,
waitFor,
screen
} from '@testing-library/react';
import '../../src';
import {clearStoresCache, render as amisRender} from '../../src';
import {makeEnv as makeEnvRaw, wait} from '../helper';
import rows from '../mockData/rows';
import type {RenderOptions} from '../../src';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
/** 避免updateLocation里的console.error */
const makeEnv = (env?: Partial<RenderOptions>) =>
makeEnvRaw({updateLocation: () => {}, ...env});
describe('inner events', () => {
test('should call the callback function if provided while double clicking a row of the crud2', async () => {
const mockFn = jest.fn();
render(
amisRender(
{
type: 'crud2',
mode: 'table',
data: {
items: rows
},
columns: [
{
name: 'engine',
label: 'Rendering engine'
}
],
onEvent: {
rowDbClick: {
actions: [
{
actionType: 'custom',
script: mockFn
}
]
}
}
},
{}
)
);
await waitFor(() => {
const ele = screen.getAllByText('Trident');
fireEvent.dblClick(ele[0]);
expect(mockFn).toBeCalledTimes(1);
});
});
});

View File

@@ -0,0 +1,124 @@
import {
cleanup,
fireEvent,
render,
waitFor,
screen
} from '@testing-library/react';
import '../../src';
import {clearStoresCache, render as amisRender} from '../../src';
import {makeEnv as makeEnvRaw, replaceReactAriaIds, wait} from '../helper';
import rows from '../mockData/rows';
import type {RenderOptions} from '../../src';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
/** 避免updateLocation里的console.error */
const makeEnv = (env?: Partial<RenderOptions>) =>
makeEnvRaw({updateLocation: () => {}, ...env});
async function fetcher(config: any) {
return {
status: 200,
headers: {},
data: {
status: 0,
msg: '',
data: {
count: 144,
rows
}
}
};
}
test('Renderer: crud filterable', async () => {
const mockFetcher = jest.fn(fetcher);
const {container, debug, getByText} = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
syncLocation: false,
columns: [
{
name: '__id',
label: 'ID'
},
{
name: 'engine',
label: 'Rendering engine',
filterable: {
options: ['A', 'B', 'C', 'D', 'X']
}
}
]
}
},
{},
makeEnv({fetcher: mockFetcher})
)
);
await waitFor(() => {
expect(container.querySelectorAll('tbody>tr').length > 5).toBeTruthy();
});
fireEvent.click(container.querySelector('[icon="column-filter"]')!);
await waitFor(() => {
expect(container.querySelector('.cxd-PopOver')).toBeInTheDocument();
});
});
test('Renderer: crud filterable searchable', async () => {
const mockFetcher = jest.fn(fetcher);
const {container, debug, getByText} = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
syncLocation: false,
columns: [
{
name: '__id',
label: 'ID'
},
{
name: 'engine',
label: 'Rendering engine',
filterable: {
searchable: true,
options: ['A', 'B', 'C', 'D', 'X']
}
}
]
}
},
{},
makeEnv({fetcher: mockFetcher})
)
);
await waitFor(() => {
expect(container.querySelectorAll('tbody>tr').length > 5).toBeTruthy();
});
fireEvent.click(container.querySelector('[icon="column-filter"]')!);
await waitFor(() => {
expect(container.querySelector('.cxd-PopOver')).toBeInTheDocument();
});
await waitFor(() => {
expect(container.querySelector('.cxd-SearchBox')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,661 @@
import {
render,
fireEvent,
waitFor,
cleanup,
screen
} from '@testing-library/react';
import '../../src';
import {render as amisRender, clearStoresCache} from '../../src';
import {makeEnv, wait} from '../helper';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
// 验证 crud 里面的 ajax 动作,结束后是否刷新 crud
test('CRUD reload ajax1', async () => {
let listApiCalledCount = 0;
const mockFetcher = jest.fn().mockImplementation((api: any) => {
if (/^\/api\/mock2\/sample\/\d+/.test(api.url)) {
return Promise.resolve({
data: {
status: 0
}
});
}
listApiCalledCount++;
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
},
{
label: '操作',
type: 'operation',
buttons: [
{
label: '保存',
type: 'button',
actionType: 'ajax',
api: '/api/mock2/sample/${id}'
}
]
}
]
}
},
{},
makeEnv({fetcher: mockFetcher})
)
);
await wait(200);
const saveBtn = container.querySelectorAll('tbody>tr button')[0];
expect(saveBtn).toBeTruthy();
fireEvent.click(saveBtn);
await waitFor(() => {
expect(mockFetcher).toBeCalledTimes(3);
});
expect(listApiCalledCount).toBe(2);
});
// 如果配置了 reload none 则不刷新
test('CRUD reload ajax2', async () => {
let listApiCalledCount = 0;
const mockFetcher = jest.fn().mockImplementation((api: any) => {
if (/^\/api\/mock2\/sample\/\d+/.test(api.url)) {
return Promise.resolve({
data: {
status: 0
}
});
}
listApiCalledCount++;
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
},
{
label: '操作',
type: 'operation',
buttons: [
{
label: '保存',
type: 'button',
actionType: 'ajax',
api: '/api/mock2/sample/${id}'
},
{
label: '保存2',
type: 'button',
actionType: 'ajax',
api: '/api/mock2/sample/${id}',
reload: 'none'
}
]
}
]
}
},
{},
makeEnv({fetcher: mockFetcher})
)
);
await wait(200);
const saveBtn1 = container.querySelectorAll('tbody>tr button')[0];
const saveBtn2 = container.querySelectorAll('tbody>tr button')[1];
expect(saveBtn1).toBeTruthy();
expect(saveBtn2).toBeTruthy();
fireEvent.click(saveBtn2);
await waitFor(() => {
expect(mockFetcher).toBeCalledTimes(2);
});
expect(listApiCalledCount).toBe(1);
fireEvent.click(saveBtn1);
await waitFor(() => {
expect(mockFetcher).toBeCalledTimes(4);
});
expect(listApiCalledCount).toBe(2);
});
// dialog 提交后应该刷新 crud
test('CRUD reload dialog1', async () => {
let listApiCalledCount = 0;
const mockFetcher = jest.fn().mockImplementation((api: any) => {
if (/^\/api\/mock2\/sample\/\d+/.test(api.url)) {
return Promise.resolve({
data: {
status: 0
}
});
}
listApiCalledCount++;
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
},
{
label: '操作',
type: 'operation',
buttons: [
{
label: 'OpenDialog',
type: 'button',
actionType: 'dialog',
dialog: {
body: {
type: 'form',
api: '/api/mock2/sample/${id}',
body: [
{
type: 'input-text',
name: 'a',
label: 'A'
}
]
}
}
}
]
}
]
}
},
{},
makeEnv({fetcher: mockFetcher, getModalContainer: () => container})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
await wait(200);
const saveBtn = container.querySelectorAll('tbody>tr button')[0];
expect(saveBtn).toBeTruthy();
fireEvent.click(saveBtn);
await wait(300);
expect(getByText('确认')).toBeInTheDocument();
fireEvent.click(getByText('取消'));
await wait(300);
fireEvent.click(saveBtn);
await wait(300);
expect(getByText('确认')).toBeInTheDocument();
fireEvent.click(getByText('确认'));
await wait(500);
expect(mockFetcher).toBeCalledTimes(3);
expect(listApiCalledCount).toBe(2);
});
// dialog 提交后如果配置列不刷新,则不刷新
test('CRUD reload dialog2', async () => {
let listApiCalledCount = 0;
const mockFetcher = jest.fn().mockImplementation((api: any) => {
if (/^\/api\/mock2\/sample\/\d+/.test(api.url)) {
return Promise.resolve({
data: {
status: 0
}
});
}
listApiCalledCount++;
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
},
{
label: '操作',
type: 'operation',
buttons: [
{
label: 'OpenDialog',
type: 'button',
actionType: 'dialog',
reload: 'none',
dialog: {
body: {
type: 'form',
api: '/api/mock2/sample/${id}',
body: [
{
type: 'input-text',
name: 'a',
label: 'A'
}
]
}
}
}
]
}
]
}
},
{},
makeEnv({fetcher: mockFetcher, getModalContainer: () => container})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
await wait(200);
const saveBtn = container.querySelectorAll('tbody>tr button')[0];
expect(saveBtn).toBeTruthy();
fireEvent.click(saveBtn);
await wait(300);
fireEvent.click(saveBtn);
await wait(300);
expect(getByText('确认')).toBeInTheDocument();
fireEvent.click(getByText('确认'));
await wait(500);
expect(mockFetcher).toBeCalledTimes(2);
expect(listApiCalledCount).toBe(1);
});
// drawer 提交后应该刷新 crud
test('CRUD reload drawer1', async () => {
let listApiCalledCount = 0;
const mockFetcher = jest.fn().mockImplementation((api: any) => {
if (/^\/api\/mock2\/sample\/\d+/.test(api.url)) {
return Promise.resolve({
data: {
status: 0
}
});
}
listApiCalledCount++;
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
},
{
label: '操作',
type: 'operation',
buttons: [
{
label: 'openDrawer',
type: 'button',
actionType: 'drawer',
drawer: {
body: {
type: 'form',
api: '/api/mock2/sample/${id}',
body: [
{
type: 'input-text',
name: 'a',
label: 'A'
}
]
}
}
}
]
}
]
}
},
{},
makeEnv({fetcher: mockFetcher, getModalContainer: () => container})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
await wait(200);
const saveBtn = container.querySelectorAll('tbody>tr button')[0];
expect(saveBtn).toBeTruthy();
fireEvent.click(saveBtn);
await wait(300);
expect(getByText('确认')).toBeInTheDocument();
fireEvent.click(getByText('取消'));
await wait(300);
fireEvent.click(saveBtn);
await wait(300);
expect(getByText('确认')).toBeInTheDocument();
fireEvent.click(getByText('确认'));
await wait(500);
expect(mockFetcher).toBeCalledTimes(3);
expect(listApiCalledCount).toBe(2);
});
// dialog 提交后如果配置列不刷新,则不刷新
test('CRUD reload drawer2', async () => {
let listApiCalledCount = 0;
const mockFetcher = jest.fn().mockImplementation((api: any) => {
if (/^\/api\/mock2\/sample\/\d+/.test(api.url)) {
return Promise.resolve({
data: {
status: 0
}
});
}
listApiCalledCount++;
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
api: '/api/mock2/sample',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
},
{
label: '操作',
type: 'operation',
buttons: [
{
label: 'openDrawer',
type: 'button',
actionType: 'drawer',
reload: 'none',
drawer: {
body: {
type: 'form',
api: '/api/mock2/sample/${id}',
body: [
{
type: 'input-text',
name: 'a',
label: 'A'
}
]
}
}
}
]
}
]
}
},
{},
makeEnv({fetcher: mockFetcher, getModalContainer: () => container})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
await wait(200);
const saveBtn = container.querySelectorAll('tbody>tr button')[0];
expect(saveBtn).toBeTruthy();
fireEvent.click(saveBtn);
await wait(300);
fireEvent.click(saveBtn);
await wait(300);
expect(getByText('确认')).toBeInTheDocument();
fireEvent.click(getByText('确认'));
await wait(500);
expect(mockFetcher).toBeCalledTimes(2);
expect(listApiCalledCount).toBe(1);
});
test('reload event triggered and clear selectedItems & unselectedItems', async () => {
const mockFetcher = jest.fn(async function fetcher(config: any) {
return {
status: 200,
headers: {},
data: {
status: 0,
msg: '',
data: {
count: 3,
items: [
{id: 1, name: 'amis1'},
{id: 2, name: 'amis2'},
{id: 3, name: 'amis3'}
]
}
}
};
});
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'crud',
id: 'crud',
api: '/api/mock2/sample',
syncLocation: false,
keepItemSelectionOnPageChange: true,
bulkActions: [
{
type: 'action',
align: 'right',
icon: 'iconfont icon-refresh',
label: '刷新(actionType)',
tooltip: '',
level: 'primary',
actionType: 'reload',
target: 'crud'
}
],
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'name',
label: 'name'
},
{
type: 'container',
label: '操作',
body: [
{
label: '删除',
type: 'action',
level: 'danger',
className: 'deleteBtn',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
args: {
api: '/api/mock2/sample' /** mock */
}
},
{
actionType: 'reload',
componentId: 'crud',
dataMergeMode: 'override'
}
]
}
}
}
]
}
]
}
},
{},
makeEnv({fetcher: mockFetcher})
)
);
await waitFor(() => {
expect(container.querySelectorAll('tbody>tr').length).toEqual(3);
expect(container.querySelectorAll('tbody>tr.is-checked').length).toEqual(0);
});
fireEvent.click(
container.querySelector('.cxd-Table-checkCell input[type="checkbox"]')!
);
await wait(200);
expect(container.querySelectorAll('tbody>tr.is-checked').length).toEqual(3);
/** 触发reload后勾选项清空 */
const deleteBtn = container.querySelector('.cxd-Button.deleteBtn');
expect(deleteBtn).toBeInTheDocument();
fireEvent.click(deleteBtn!);
await wait(500);
expect(container.querySelectorAll('tbody>tr.is-checked').length).toEqual(0);
});

View File

@@ -0,0 +1,321 @@
import {
cleanup,
fireEvent,
render,
waitFor,
screen
} from '@testing-library/react';
import '../../src';
import {clearStoresCache, render as amisRender} from '../../src';
import {makeEnv as makeEnvRaw, replaceReactAriaIds, wait} from '../helper';
import rows from '../mockData/rows';
import type {RenderOptions} from '../../src';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
/** 避免updateLocation里的console.error */
const makeEnv = (env?: Partial<RenderOptions>) =>
makeEnvRaw({updateLocation: () => {}, ...env});
// 主要用来验证是否可以回显正确,如果外部存在同名变量是否不影响 filter
test('CRUD filter1', async () => {
const mockFetcher = jest.fn().mockImplementation((api: any) => {
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
const {container} = render(
amisRender(
{
type: 'page',
data: {b: '2'},
body: {
type: 'crud',
api: '/api/mock2/sample',
filter: {
body: [
{
type: 'input-text',
name: 'a'
},
{
type: 'input-text',
name: 'b'
}
]
},
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
}
]
}
},
{
location: {
pathname: '/mock2/sample',
search: '?a=1',
query: ''
} as any
},
makeEnv({fetcher: mockFetcher})
)
);
await wait(500);
const a = container.querySelector('input[name="a"]')!;
const b = container.querySelector('input[name="b"]')!;
expect(a).toBeTruthy();
expect(a.nodeValue).not.toBe('1');
// 因为数据不在 query 里面,所以不显示是正常的
expect(b).toBeTruthy();
expect(b.nodeValue).not.toBe('');
});
// 验证 autoGenerateFilter 模式是否表现一致
test('CRUD filter2', async () => {
const mockFetcher = jest.fn().mockImplementation((api: any) => {
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
const {container} = render(
amisRender(
{
type: 'page',
data: {b: '2'},
body: {
type: 'crud',
api: '/api/mock2/sample',
autoGenerateFilter: true,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
searchable: true,
label: 'A'
},
{
name: 'b',
searchable: true,
label: 'B'
}
]
}
},
{
location: {
pathname: '/mock2/sample',
search: '?a=1',
query: ''
} as any
},
makeEnv({fetcher: mockFetcher})
)
);
await wait(500);
const a = container.querySelector('input[name="a"]')!;
const b = container.querySelector('input[name="b"]')!;
expect(a).toBeTruthy();
expect(a.nodeValue).not.toBe('1');
// 因为数据不在 query 里面,所以不显示是正常的
expect(b).toBeTruthy();
expect(b.nodeValue).not.toBe('');
});
// picker 的话,不应该回显任何数据
test('Picker filter1', async () => {
const mockFetcher = jest.fn().mockImplementation((api: any) => {
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
data: {b: '2'},
body: {
type: 'form',
body: [
{
type: 'picker',
name: 'xxx',
source: '/api/mock2/sample',
pickerSchema: {
type: 'crud',
filter: {
body: [
{
type: 'input-text',
name: 'a'
},
{
type: 'input-text',
name: 'b'
}
]
},
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A'
},
{
name: 'b',
label: 'B'
}
]
}
}
]
}
},
{
location: {
pathname: '/mock2/sample',
search: '?a=1',
query: ''
} as any
},
makeEnv({fetcher: mockFetcher, getModalContainer: () => container} as any)
)
);
container = renderResult.container;
await wait(200);
const pickerBtn = container.querySelector('span.cxd-Picker-btn')!;
expect(pickerBtn).toBeTruthy();
fireEvent.click(pickerBtn);
await wait(1000);
const a = container.querySelector('input[name="a"]')!;
const b = container.querySelector('input[name="b"]')!;
// picker 里面不应该自动回显任何数据
expect(a).toBeTruthy();
expect(a.nodeValue).not.toBe('');
// picker 里面不应该自动回显任何数据
expect(b).toBeTruthy();
expect(b.nodeValue).not.toBe('');
});
// picker 的话,不应该回显任何数据
// autoGenerateFilter 模式也一样
test('Picker filter2', async () => {
const mockFetcher = jest.fn().mockImplementation((api: any) => {
return Promise.resolve({
data: {
status: 0,
data: {
items: [{id: 1, a: 'a1', b: 'b1'}]
}
}
});
});
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'page',
data: {b: '2'},
body: {
type: 'form',
body: [
{
type: 'picker',
name: 'xxx',
source: '/api/mock2/sample',
pickerSchema: {
type: 'crud',
autoGenerateFilter: true,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'a',
label: 'A',
searchable: true
},
{
name: 'b',
label: 'B',
searchable: true
}
]
}
}
]
}
},
{
location: {
pathname: '/mock2/sample',
search: '?a=1',
query: ''
} as any
},
makeEnv({fetcher: mockFetcher, getModalContainer: () => container} as any)
)
);
container = renderResult.container;
await wait(200);
const pickerBtn = container.querySelector('span.cxd-Picker-btn')!;
expect(pickerBtn).toBeTruthy();
fireEvent.click(pickerBtn);
await wait(1000);
const a = container.querySelector('input[name="a"]')!;
const b = container.querySelector('input[name="b"]')!;
// picker 里面不应该自动回显任何数据
expect(a).toBeTruthy();
expect(a.nodeValue).not.toBe('');
// picker 里面不应该自动回显任何数据
expect(b).toBeTruthy();
expect(b.nodeValue).not.toBe('');
});

View File

@@ -0,0 +1,473 @@
import React = require('react');
import {render} from '@testing-library/react';
import * as renderer from 'react-test-renderer';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('Renderer:card', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'card',
className: 'className',
header: {
title: '标题'
},
href: 'href',
body: '这里是内容',
bodyClassName: 'bodyClassName',
actions: [
{
type: 'button',
label: '编辑',
actionType: 'dialog',
dialog: {
title: '编辑',
body: '你正在编辑该卡片'
}
},
{
type: 'button',
label: '删除',
actionType: 'dialog',
dialog: {
title: '提示',
body: '你删掉了该卡片'
}
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:cards color', () => {
const {container} = render(
amisRender(
{
type: 'page',
data: {
items: [
{
engine: 'Trident',
browser: 'Internet Explorer 4.0'
},
{
engine: 'Chrome',
browser: 'Chrome 44'
},
{
engine: 'Gecko',
browser: 'Firefox 1.0'
},
{
engine: 'Presto',
browser: 'Opera 10'
},
{
engine: 'Webkie',
browser: 'Safari 12'
}
]
},
body: {
type: 'cards',
source: '$items',
card: {
header: {
avatarText: '${engine|substring:0:2|upperCase}',
avatarTextBackground: [
'#FFB900',
'#D83B01',
'#B50E0E',
'#E81123',
'#B4009E',
'#5C2D91',
'#0078D7',
'#00B4FF',
'#008272'
]
},
body: [
{
label: 'Browser',
name: 'browser'
}
]
}
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:cards media', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'card',
header: {
title: '标题'
},
media: {
type: 'image',
className: 'w-36 h-24',
url: 'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80',
position: 'left',
isLive: false,
autoPlay: false,
poster: false
},
body: '这里是内容',
secondary: '次要说明',
actions: [
{
type: 'button',
label: '操作',
actionType: 'dialog',
className: 'mr-4',
dialog: {
title: '操作',
body: '你正在编辑该卡片'
}
},
{
type: 'button',
label: '操作',
actionType: 'dialog',
className: 'mr-2.5',
dialog: {
title: '操作',
body: '你正在编辑该卡片'
}
},
{
type: 'dropdown-button',
level: 'link',
icon: 'fa fa-ellipsis-h',
className: 'pr-1 flex',
hideCaret: true,
buttons: [
{
type: 'button',
label: '编辑',
actionType: 'dialog',
dialog: {
title: '编辑',
body: '你正在编辑该卡片'
}
},
{
type: 'button',
label: '删除',
actionType: 'dialog',
dialog: {
title: '提示',
body: '你删掉了该卡片'
}
}
]
}
],
toolbar: [
{
type: 'tpl',
tpl: '标签',
className: 'label label-warning'
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:cards hightlight', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'card',
header: {
title: '标题',
highlight: true,
highlightClassName: 'test-highlight-class'
},
media: {
type: 'image',
className: 'w-36 h-24',
url: 'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80',
position: 'left'
},
body: '这里是内容',
secondary: '次要说明',
actions: [
{
type: 'button',
label: '操作',
actionType: 'dialog',
className: 'mr-4',
dialog: {
title: '操作',
body: '你正在编辑该卡片'
}
},
{
type: 'button',
label: '操作',
actionType: 'dialog',
className: 'mr-2.5',
dialog: {
title: '操作',
body: '你正在编辑该卡片'
}
},
{
type: 'dropdown-button',
level: 'link',
icon: 'fa fa-ellipsis-h',
className: 'pr-1 flex',
hideCaret: true,
buttons: [
{
type: 'button',
label: '编辑',
actionType: 'dialog',
dialog: {
title: '编辑',
body: '你正在编辑该卡片'
}
},
{
type: 'button',
label: '删除',
actionType: 'dialog',
dialog: {
title: '提示',
body: '你删掉了该卡片'
}
}
]
}
],
toolbar: [
{
type: 'tpl',
tpl: '标签',
className: 'label label-warning'
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:cards hightlight', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'card',
header: {
title: '标题',
highlight: true,
highlightClassName: 'test-highlight-class'
},
media: {
type: 'image',
className: 'w-36 h-24',
url: 'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80',
position: 'left'
},
body: '这里是内容',
secondary: '次要说明',
actions: [
{
type: 'button',
label: '操作',
actionType: 'dialog',
className: 'mr-4',
dialog: {
title: '操作',
body: '你正在编辑该卡片'
}
},
{
type: 'button',
label: '操作',
actionType: 'dialog',
className: 'mr-2.5',
dialog: {
title: '操作',
body: '你正在编辑该卡片'
}
},
{
type: 'dropdown-button',
level: 'link',
icon: 'fa fa-ellipsis-h',
className: 'pr-1 flex',
hideCaret: true,
buttons: [
{
type: 'button',
label: '编辑',
actionType: 'dialog',
dialog: {
title: '编辑',
body: '你正在编辑该卡片'
}
},
{
type: 'button',
label: '删除',
actionType: 'dialog',
dialog: {
title: '提示',
body: '你删掉了该卡片'
}
}
]
}
],
toolbar: [
{
type: 'tpl',
tpl: '标签',
className: 'label label-warning'
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:card with expression in className property', async () => {
const {container} = render(
amisRender(
{
type: 'page',
data: {
"mockTrue": true,
"mockFalse": false,
"status": "success"
},
body: {
type: 'card',
className: "bg-${status}",
header: {
className: {
"mockClassName1": "${mockTrue === true}",
"mockClassName2": "${mockFalse === true}"
},
title: '标题'
},
href: 'href',
body: '这里是内容',
bodyClassName: 'bodyClassName'
}
},
{},
makeEnv({})
)
);
expect(container).toBeInTheDocument();
await wait(200);
const card = container.querySelector('.cxd-Card');
const head = container.querySelector('.cxd-Card .cxd-Card-heading');
expect(card?.classList).toContain('bg-success');
expect(head?.classList).toContain('mockClassName1');
})
test('Renderer:cards with expression in className property', async () => {
const {container} = render(
amisRender(
{
type: 'page',
data: {
items: [
{
engine: 'Trident',
browser: 'Internet Explorer 4.0',
mockField: "abc"
},
{
engine: 'Chrome',
browser: 'Chrome 44',
mockField: 'def'
}
]
},
body: {
type: 'cards',
source: '$items',
card: {
className: {
'mockClassName1': 'this.mockField === "abc"',
'mockClassName2': 'this.mockField === "abcd"',
'mockClassName3': '${mockField === "def"}',
'mockClassName4': '${mockField === "defg"}'
},
body: [
{
"label": "Engine",
"name": "engine"
},
{
"label": "Browser",
"name": "browser"
}
]
}
}
},
{},
makeEnv({})
)
);
expect(container).toBeInTheDocument();
await wait(200);
const cardList = container.querySelectorAll('.cxd-Cards .cxd-Card');
expect(cardList.length).toEqual(2);
expect(cardList[0].classList).toContain('mockClassName1');
expect(cardList[1].classList).toContain('mockClassName3');
});

View File

@@ -0,0 +1,271 @@
/**
* 组件名称:Carousel 轮播图
* 单测内容:
* 1. 基础使用
* 2. auto & interval & duration
* 3. name & option config
* 4. controls & controlsTheme & thumbMode
* 5. itemSchema & width & height
*/
import React from 'react';
import {render, fireEvent, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('Renderer:Carousel', async () => {
const {container} = render(
amisRender(
{
type: 'carousel',
controlsTheme: 'light',
width: '500',
height: '300',
options: [
{
image:
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png',
title: '标题',
titleClassName: 'block',
description: '描述',
descriptionClassName: 'block'
},
{
html: '<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
},
{
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
}
],
className: 'show'
},
{},
makeEnv({})
)
);
const image = container.querySelector('div.cxd-Carousel-item');
fireEvent.mouseEnter(image as HTMLDivElement);
const leftArrow = container.querySelector('div.cxd-Carousel-leftArrow');
fireEvent.click(leftArrow as HTMLDivElement);
const rightArrow = container.querySelector('div.cxd-Carousel-rightArrow');
fireEvent.click(rightArrow as HTMLDivElement);
// 等到第二个点变成激活状态
await waitFor(() => {
expect(
container.querySelector('span:nth-child(2).is-active')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('Renderer:Carousel with auto & interval & duration', async () => {
const {container} = render(
amisRender(
{
type: 'carousel',
controlsTheme: 'light',
width: '500',
height: '300',
auto: true,
interval: 2000,
duration: 500,
options: [
{
image:
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png',
title: '标题',
titleClassName: 'block',
description: '描述',
descriptionClassName: 'block'
},
{
html: '<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
},
{
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
}
],
className: 'show'
},
{},
makeEnv({})
)
);
await wait(2500);
expect(container.querySelector('.cxd-Carousel-dot:nth-child(2)')).toHaveClass(
'is-active'
);
});
test('Renderer:Carousel with name & option config', async () => {
const {container} = render(
amisRender(
{
type: 'page',
data: {
imageList: [
{
image:
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png',
imageClassName: 'thisisimageClassName',
title: '这是标题',
titleClassName: 'thiisistitleClassName',
description: '这是描述',
href: 'https://www.baidu.com'
},
{
html: '<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
}
]
},
body: [
{
type: 'carousel',
auto: false,
name: 'imageList'
}
]
},
{},
makeEnv({})
)
);
const item = container.querySelector('.cxd-Carousel-item')!;
expect(item.firstElementChild).toHaveAttribute(
'href',
'https://www.baidu.com'
);
expect(item).toHaveTextContent('这是标题');
expect(item).toHaveTextContent('这是描述');
fireEvent.click(container.querySelector('.cxd-Carousel-dot:nth-child(2)')!);
await waitFor(() => {
expect(container.querySelector('.cxd-Carousel-item')!).toHaveTextContent(
'carousel data'
);
});
});
test('Renderer:Carousel with controls & controlsTheme & thumbMode', async () => {
const {container, rerender} = render(
amisRender(
{
type: 'carousel',
controlsTheme: 'light',
thumbMode: 'contain',
controls: ['dots', 'arrows'],
options: [
{
image:
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png'
},
{
html: '<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
},
{
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
}
]
},
{},
makeEnv({})
)
);
expect(container.querySelector('.cxd-Carousel')).toHaveClass(
'cxd-Carousel--light'
);
expect(
container.querySelector('.cxd-Image-origin.cxd-Image-origin--contain')
).toBeInTheDocument();
expect(
container.querySelector('.cxd-Carousel-dotsControl')
).toBeInTheDocument();
expect(
container.querySelector('.cxd-Carousel-leftArrow')
).toBeInTheDocument();
rerender(
amisRender(
{
type: 'carousel',
controlsTheme: 'dark',
thumbMode: 'cover',
controls: [],
options: [
{
image:
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png'
},
{
html: '<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
},
{
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
expect(container.querySelector('.cxd-Carousel')).toHaveClass(
'cxd-Carousel--dark'
);
expect(
container.querySelector('.cxd-Image-origin.cxd-Image-origin--cover')
).toBeInTheDocument();
expect(
container.querySelector('.cxd-Carousel-dotsControl')
).not.toBeInTheDocument();
expect(
container.querySelector('.cxd-Carousel-leftArrow')
).not.toBeInTheDocument();
});
test('Renderer:Carousel with itemSchema & width & height', async () => {
const {container, rerender} = render(
amisRender(
{
type: 'carousel',
options: [
{
image:
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png'
}
],
itemSchema: {
type: 'tpl',
tpl: '<div class="itemSchemaClassName" style="background-image: url(\'<%= data.image %>\');"></div>'
},
width: 101,
height: 99
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
expect(container.querySelector('.cxd-Carousel')).toHaveStyle({
width: '101px',
height: '99px'
});
expect(container.querySelector('.itemSchemaClassName')).toBeInTheDocument();
});

View File

@@ -0,0 +1,267 @@
/**
* 组件名称:Collapse 折叠器
*
* 单测内容:
* 1. 基本用法
* 2. accordion 手风琴模式
* 3. 自定义图标
* 4. disabled 禁用 和 面板嵌套
* 5. enableFieldSetStyle属性控制CollapseGroup组件在Form中的样式
*/
import {render, fireEvent, waitFor} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
// 1. 基本用法
test('1. Renderer:Collapse', async () => {
const {container} = render(
amisRender(
{
type: 'collapse-group',
activeKey: ['1', '2'],
body: [
{
type: 'collapse',
key: '1',
header: '标题1',
body: '这里是内容1'
},
{
type: 'collapse',
key: '2',
header: '标题2',
body: '这里是内容2'
},
{
type: 'collapse',
key: '3',
header: '标题3',
body: '这里是内容3'
}
]
},
{},
makeEnv({})
)
);
const items = container.querySelectorAll(
'.cxd-CollapseGroup > .cxd-Collapse'
);
expect(items.length).toBe(3);
expect(items[0]).toHaveClass('is-active');
expect(items[1]).toHaveClass('is-active');
expect(items[2]).not.toHaveClass('is-active');
fireEvent.click(items[2].firstElementChild!);
await wait(200);
expect(items[2]).toHaveClass('is-active');
expect(container).toMatchSnapshot();
});
// 2. accordion 手风琴模式
test('2. Renderer:Collapse with accordion', async () => {
const {container} = render(
amisRender(
{
type: 'collapse-group',
activeKey: ['1'],
accordion: true,
body: [
{
type: 'collapse',
key: '1',
header: '标题1',
body: '这里是内容1'
},
{
type: 'collapse',
key: '2',
header: '标题2',
body: '这里是内容2'
},
{
type: 'collapse',
key: '3',
header: '标题3',
body: '这里是内容3'
}
]
},
{},
makeEnv({})
)
);
const items = container.querySelectorAll(
'.cxd-CollapseGroup > .cxd-Collapse'
);
expect(items.length).toBe(3);
expect(items[0]).toHaveClass('is-active');
expect(items[1]).not.toHaveClass('is-active');
expect(items[2]).not.toHaveClass('is-active');
fireEvent.click(items[2].firstElementChild!);
await wait(200);
expect(items[0]).not.toHaveClass('is-active');
expect(items[1]).not.toHaveClass('is-active');
expect(items[2]).toHaveClass('is-active');
});
// 3. 自定义图标
test('3. Renderer:Collapse with expandIcon & expandIconPosition & showArrow', async () => {
const schema = {
type: 'collapse-group',
activeKey: ['1'],
expandIcon: {
type: 'icon',
icon: 'caret-right'
},
body: [
{
type: 'collapse',
key: '1',
header: '标题1',
body: '这里是内容1'
},
{
type: 'collapse',
key: '2',
header: '标题2',
body: '这里是内容2'
},
{
type: 'collapse',
key: '3',
header: '标题3',
body: '这里是内容3',
showArrow: false
}
]
};
const {container, rerender} = render(amisRender(schema, {}, makeEnv({})));
const item = container.querySelector(
'.cxd-Collapse.is-active .cxd-Collapse-icon-tranform'
)!;
expect(item).toHaveClass('fa-caret-right');
expect(
container.querySelector('.cxd-Collapse:last-of-type')!.firstElementChild!
).not.toHaveClass('cxd-Collapse-icon-tranform');
rerender(
amisRender({...schema, expandIconPosition: 'right'}, {}, makeEnv({}))
);
await wait(200);
expect(container.querySelector('.cxd-CollapseGroup')!).toHaveClass(
'icon-position-right'
);
expect(container).toMatchSnapshot();
});
// 4. disabled 禁用 和 面板嵌套
test('4. Renderer:Collapse with disabled & panel nesting', async () => {
const schema = {
type: 'collapse-group',
activeKey: ['1'],
body: [
{
type: 'collapse',
key: '1',
header: '标题1',
body: {
type: 'collapse-group',
activeKey: ['1'],
body: [
{
type: 'collapse',
key: '1',
header: '嵌套面板标题',
body: '嵌套面板内容'
}
]
}
},
{
type: 'collapse',
key: '3',
header: '标题3',
body: '这里是内容3',
className: 'lastOne',
disabled: true
}
]
};
const {container, rerender} = render(amisRender(schema, {}, makeEnv({})));
expect(container).toMatchSnapshot();
expect(
container.querySelector('.cxd-Collapse-content')!.firstElementChild!
).toHaveClass('cxd-CollapseGroup');
expect(container.querySelector('.lastOne')!).toHaveClass(
'cxd-Collapse--disabled'
);
});
test('5. enableFieldSetStyle属性控制CollapseGroup组件在Form中的样式', async () => {
const {container} = render(
amisRender(
{
"type": "form",
"body": [
{
"type": "collapse-group",
"body": [
{
"type": "collapse",
"key": "1",
"header": "标题1",
"body": "这里是内容1"
},
{
"type": "collapse",
"key": "2",
"header": "标题2",
"body": "这里是内容2"
}
]
},
{
"type": "collapse-group",
"enableFieldSetStyle": false,
"body": [
{
"type": "collapse",
"key": "1",
"header": "标题1",
"body": "这里是内容1"
},
{
"type": "collapse",
"key": "2",
"header": "标题2",
"body": "这里是内容2"
}
]
}
]
},
{},
makeEnv({})
)
);
const totalCollections = container.querySelectorAll(
'.cxd-CollapseGroup > .cxd-Collapse'
);
const disabledStyleCollections = container.querySelectorAll(
'.cxd-CollapseGroup > .cxd-Collapse-fieldset--disabled'
);
expect(totalCollections.length).toBe(4);
expect(disabledStyleCollections.length).toBe(2);
})

View File

@@ -0,0 +1,33 @@
import React = require('react');
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:container', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'container',
className: 'bg-white',
body: [
{
type: 'tpl',
tpl: '内容1'
},
{
type: 'plain',
tpl: '内容2'
}
]
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,31 @@
import React = require('react');
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:custom', () => {
const {container} = render(
amisRender(
{
type: 'custom',
name: 'myName',
className: 'amis-custom-demo',
html: '<div><h2>hello, world!</h2></div>',
label: '自定义组件',
onMount: (dom: HTMLElement, value: any, onChange: any, props: any) => {
const button = document.createElement('button');
button.innerText = '点击修改';
button.onclick = event => {
event.preventDefault();
};
dom.appendChild(button);
}
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,132 @@
import React = require('react');
import {render, fireEvent} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
import moment from 'moment';
import {act} from 'react-test-renderer';
test('Renderer:date', async () => {
const {container} = render(
amisRender(
{
type: 'date',
name: 'date',
label: 'date',
value: '1559836800',
valueFormat: 'YYYY-MM-DD',
placeholder: '请选择时间',
minDate: '1559664000',
maxDate: '1561737600',
className: 'show'
},
{},
makeEnv({})
)
);
const input = container.querySelector('.cxd-DateField');
expect(input?.innerHTML).toEqual(
moment('1559836800', 'X').format('YYYY-MM-DD')
);
expect(container).toMatchSnapshot();
});
test('Renderer:date reset', async () => {
const {container, getByText} = render(
amisRender(
{
type: 'form',
title: '表单',
body: [
{
label:
'本月第一天$ {_|now|dateModify:startOf:month|date:YYYY-MM-DD}',
type: 'input-date',
name: 'month',
value: '${_|now|dateModify:startOf:month|date:YYYY-MM-DD}',
minDate: '',
maxDate: '',
format: 'YYYY-MM-DD',
inputFormat: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD'
},
{
type: 'reset',
label: '重置',
actionType: 'reset',
dialog: {
title: '系统提示',
body: '对你点击了'
},
id: 'u:862532a9f698',
level: 'dark'
}
],
id: 'u:7c281facfdbb'
},
{},
makeEnv({})
)
);
const inputElement = container.querySelector('input[type="text"]') as any;
const defaultValue = inputElement?.value;
// 打开日期选择器
fireEvent.click(inputElement);
// 更换月份
fireEvent.click(container.querySelector('[icon="right-arrow"]')!);
// 选择一个新的日期
fireEvent.click(container.querySelector('td[data-value="1"]')!);
// 新选的日期与旧的不同
expect(inputElement?.value !== defaultValue).toBeTruthy();
// 点击重制
await act(() => {
fireEvent.click(container.querySelector('button[type="reset"]')!);
});
// 重制后的日期 等于初始化的日期
expect(inputElement?.value === defaultValue).toBeTruthy();
});
test('Renderer:date defaultValue', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
data: {updateTime: 1680255708}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: {
url: '/amis/initData',
method: 'GET'
},
title: '编辑',
body: [
{
type: 'input-date',
label: '日期',
name: 'updateTime',
format: 'YYYY-MM-DD',
value: '${NOW()}'
}
]
},
{},
makeEnv({
fetcher
})
)
);
await wait(500);
const inputElement = container.querySelector('input[type="text"]') as any;
expect(inputElement?.value).toBe('2023-03-31'); // 默认值的优先级没有接口返回的高,所以应该是 2023-03-31
});

View File

@@ -0,0 +1,193 @@
import {
cleanup,
fireEvent,
render,
waitFor,
screen
} from '@testing-library/react';
import '../../src';
import {clearStoresCache, render as amisRender} from '../../src';
import {makeEnv as makeEnvRaw, replaceReactAriaIds, wait} from '../helper';
import rows from '../mockData/rows';
import type {RenderOptions} from '../../src';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
/** 避免updateLocation里的console.error */
const makeEnv = (env?: Partial<RenderOptions>) =>
makeEnvRaw({updateLocation: () => {}, ...env});
/**
* https://github.com/baidu/amis/issues/1405
*
* 验证弹窗的 CRUD 中再次弹出一个 crud,里面的 crud 确认关闭,不会关闭外面的 crud
*/
test('1. Renderer:dialog inner crud close outter crud component', async () => {
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: {
type: 'button',
label: '第一层弹框',
actionType: 'dialog',
dialog: {
title: '第一层弹框标题',
body: [
{
type: 'button',
label: '第二次弹框',
actionType: 'dialog',
dialog: {
title: '第二层弹框标题',
body: [
{
type: 'tpl',
tpl: '对你点击了',
inline: false
},
{
type: 'crud',
api: '',
columns: [
{
name: 'id',
label: 'ID',
type: 'text'
},
{
name: 'engine',
label: '渲染引擎',
type: 'text'
}
]
},
{
type: 'button',
label: '按钮',
actionType: 'dialog',
dialog: {
title: '系统提示',
body: '对你点击了'
}
}
],
actions: [
{
type: 'button',
label: '第二层确认',
actionType: 'submit'
}
],
type: 'dialog'
},
size: 'md',
level: 'primary'
},
{
type: 'crud',
api: '',
columns: [
{
name: 'id',
label: 'ID',
type: 'text'
},
{
name: 'engine',
label: '渲染引擎',
type: 'text'
}
]
}
],
type: 'dialog'
},
size: 'md',
level: 'primary'
}
},
{},
makeEnv({})
)
);
// events
fireEvent.click(getByText('第一层弹框'));
await wait(200);
expect(getByText('第二次弹框')).toBeInTheDocument();
fireEvent.click(getByText('第二次弹框'));
await wait(200);
expect(getByText('第二层弹框标题')).toBeInTheDocument();
expect(getByText('第二层确认')).toBeInTheDocument();
fireEvent.click(getByText('第二层确认'));
await wait(400);
expect(getByText('第一层弹框标题')).toBeInTheDocument();
// 还有第二次弹窗的按钮,说明第一层弹窗没有关闭
expect(getByText('第二次弹框')).toBeInTheDocument();
});
/**
* https://github.com/baidu/amis/issues/9149
*
* 验证弹窗内部的 动作是通用动作时是否能正确响应。
*
* 比如弹窗里面有个按钮是页面跳转,看是否执行了页面跳转
*/
test('2. Renderer:dialog inner component with common action', async () => {
const jumpTo = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'page',
title: '表单页面',
body: [
{
label: 'OpenADialog',
type: 'button',
actionType: 'dialog',
level: 'primary',
dialog: {
body: {
type: 'form',
api: 'post:/api/smart_lvct_boards/excel',
body: [
{
label: '下载Excel模板',
type: 'action',
level: 'success',
actionType: 'url',
url: '/api/filedown/zhuban'
}
]
}
}
}
]
},
{},
makeEnv({
jumpTo
})
)
);
// events
fireEvent.click(getByText('OpenADialog'));
await wait(200);
expect(getByText('下载Excel模板')).toBeInTheDocument();
fireEvent.click(getByText('下载Excel模板'));
await wait(400);
expect(jumpTo).toBeCalledTimes(1);
expect(jumpTo.mock.calls[0][0]).toBe('/api/filedown/zhuban');
});

View File

@@ -0,0 +1,432 @@
/**
* 组件名称:DropDownButton 下拉按钮
* 单测内容:
* 1. 基础使用
* 2. 分组显示
* 3. 点击关闭 closeOnClick & closeOnOutside
* 4. 触发方式 trigger
* 5. 图标 icon & rightIcon
* 6. hideCaret
* 7. 默认展开 defaultIsOpened
* 8. 对齐方式 align
* 9. block & size
* 10. buttons level & className
*/
import React from 'react';
import {render, fireEvent} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('Renderer:dropdown-button', async () => {
const {container} = render(
amisRender(
{
type: 'dropdown-button',
level: 'primary',
buttons: [
{
type: 'button',
label: '按钮',
actionType: 'dialog',
dialog: {
title: '系统提示',
body: '对你点击了'
}
},
{
type: 'button',
label: '按钮',
actionType: 'dialog',
dialog: {
title: '系统提示',
body: '对你点击了'
}
},
{
type: 'button',
label: '按钮',
visible: false
}
],
className: 'show'
},
{},
makeEnv({})
)
);
const dropdowmButton = document.querySelector('button.cxd-Button');
fireEvent.click(dropdowmButton as HTMLDivElement);
expect(container).toMatchSnapshot();
fireEvent.click(dropdowmButton as HTMLDivElement);
expect(container).toMatchSnapshot();
});
test('Renderer:dropdown-button with buttons group', async () => {
const {container} = render(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
buttons: [
{
label: 'RD',
icon: 'fa fa-user',
children: [
{
type: 'button',
label: '前端FE'
},
{
type: 'button',
label: '后端RD'
}
]
},
{
label: 'QA',
icon: 'fa fa-user',
children: [
{
type: 'button',
label: '测试QA'
},
{
type: 'button',
label: '交付测试DQA',
disabled: true
},
{
type: 'divider'
}
]
},
{
label: 'Manager',
icon: 'fa fa-user',
children: [
{
type: 'button',
label: '项目经理PM'
},
{
type: 'button',
label: '项目管理中心PMO',
visible: false
}
]
}
]
})
);
const dropdowmButton = document.querySelector('button.cxd-Button');
fireEvent.click(dropdowmButton as HTMLDivElement);
const menus = container.querySelectorAll(
'.cxd-DropDown-menu-root > .cxd-DropDown-menu'
);
expect(container).toMatchSnapshot();
expect(menus.length).toBe(3);
expect(
container.querySelectorAll('.cxd-DropDown-menu-root .cxd-DropDown-button')!
.length
).toBe(5);
});
test('Renderer:dropdown-button with closeOnClick & closeOnOutside', async () => {
const schema = (options: any) => ({
type: 'page',
body: [
{
type: 'dropdown-button',
label: '下拉菜单',
...options,
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
},
{
type: 'button',
label: 'outside'
}
]
});
const {container, getByText, rerender} = render(
amisRender(
schema({
// closeOnClick: true,
// closeOnOutside: true,
})
)
);
fireEvent.click(document.querySelector('button.cxd-Button')!);
const isMenuExist = (exist: boolean) => {
exist
? expect(
container.querySelector('.cxd-DropDown-menu-root')!
).toBeInTheDocument()
: expect(container.querySelector('.cxd-DropDown-menu-root')!).toBeNull();
};
isMenuExist(true);
fireEvent.click(getByText('按钮1'));
await wait(500);
isMenuExist(true);
rerender(
amisRender(
schema({
closeOnClick: true
})
)
);
expect(container).toMatchSnapshot();
fireEvent.click(getByText('按钮1'));
await wait(500);
isMenuExist(false);
fireEvent.click(document.querySelector('button.cxd-Button')!);
isMenuExist(true);
fireEvent.click(getByText('outside'));
await wait(500);
isMenuExist(false);
rerender(
amisRender(
schema({
closeOnClick: true,
closeOnOutside: false
})
)
);
fireEvent.click(document.querySelector('button.cxd-Button')!);
isMenuExist(true);
fireEvent.click(getByText('outside'));
await wait(500);
isMenuExist(true);
});
test('Renderer:dropdown-button with trigger', async () => {
const {container} = render(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
trigger: 'hover',
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
})
);
fireEvent.mouseEnter(document.querySelector('button.cxd-Button')!);
await wait(200);
expect(
container.querySelector('.cxd-DropDown-menu-root')!
).toBeInTheDocument();
});
test('Renderer:dropdown-button with icon & rightIcon', async () => {
const {container} = render(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
icon: 'fa fa-home',
rightIcon: 'fa fa-ellipsis-v',
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
})
);
expect(container.querySelector('.fa-home')).toBeInTheDocument();
expect(container.querySelector('.fa-ellipsis-v')).toBeInTheDocument();
expect(container).toMatchSnapshot();
});
test('Renderer:dropdown-button with hideCaret', async () => {
const {container} = render(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
level: 'link',
icon: 'fa fa-ellipsis-h',
hideCaret: true,
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
})
);
expect(container.querySelector('.cxd-DropDown-caret')!).toBeNull();
expect(container).toMatchSnapshot();
});
test('Renderer:dropdown-button with defaultIsOpened', async () => {
const {container} = render(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
defaultIsOpened: true,
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
})
);
expect(
container.querySelector('.cxd-DropDown-menu-root')!
).toBeInTheDocument();
});
test('Renderer:dropdown-button with align', async () => {
const {container} = render(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
defaultIsOpened: true,
align: 'right',
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
})
);
expect(
container.querySelector('.cxd-DropDown-menu-root')!
).toBeInTheDocument();
expect(container.querySelector('.cxd-DropDown')!).toHaveClass(
'cxd-DropDown--alignRight'
);
});
test('Renderer:dropdown-button with block & size', async () => {
const {container, rerender} = render(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
block: true,
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
})
);
expect(container.querySelector('.cxd-DropDown')!).toHaveClass(
'cxd-DropDown--block'
);
expect(container).toMatchSnapshot();
rerender(
amisRender({
type: 'dropdown-button',
label: '下拉菜单',
size: 'lg',
buttons: [
{
type: 'button',
label: '按钮1'
},
{
type: 'button',
label: '按钮2'
}
]
})
);
expect(container.querySelector('.cxd-DropDown .cxd-Button')!).toHaveClass(
'cxd-Button--size-lg'
);
expect(container).toMatchSnapshot();
});
test('Renderer:dropdown-button buttons with className & level', async () => {
const {container} = render(
amisRender({
type: "dropdown-button",
level: "success",
label: "下拉菜单",
buttons: [
{
type: "button",
label: "按钮1",
level: "success",
className: "custom-button-class"
},
{
type: "button",
label: "按钮2"
}
]
})
);
const dropdownButton = document.querySelector('button.cxd-Button');
fireEvent.click(dropdownButton as HTMLDivElement);
expect(container.querySelectorAll('.cxd-DropDown-menu-root .cxd-DropDown-button')[0]!).toHaveClass(
'cxd-Button--success'
);
expect(container.querySelectorAll('.cxd-DropDown-menu-root .cxd-DropDown-button')[0]!).toHaveClass(
'custom-button-class'
);
});

View File

@@ -0,0 +1,125 @@
/**
* 组件名称:Each 循环渲染器
* 单测内容:
* 1. 基础使用
* 2. 对象数组的值;获取其index
* 3. 使用数据映射
* 4. Form 中静态展示
*/
import React from 'react';
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:Each basic use', async () => {
const {container} = render(
amisRender({
type: 'page',
data: {
arr: ['A', 'B', 'C']
},
body: {
type: 'each',
name: 'arr',
items: {
type: 'tpl',
tpl: "<span class='label label-default m-l-sm'><%= data.item %></span> "
}
}
})
);
const items = container.querySelectorAll('.cxd-Each .cxd-TplField');
expect(items!.length).toBe(3);
expect(items[0]).toHaveTextContent('A');
expect(container).toMatchSnapshot();
});
test('Renderer:Each with array of objects value', async () => {
const {container} = render(
amisRender({
type: 'each',
items: {
type: 'tpl',
tpl: "<span class='label label-default m-l-sm'><%= data.name %>:<%= data.index %></span> "
},
value: [{name: 'jack'}, {name: 'martin'}],
className: 'show'
})
);
const items = container.querySelectorAll('.cxd-Each .cxd-TplField');
expect(items!.length).toBe(2);
expect(items[1]).toHaveTextContent('martin:1');
expect(container).toMatchSnapshot();
});
test('Renderer:Each with source', async () => {
const {container} = render(
amisRender({
type: 'page',
data: {
arr: [
{
name: 'jerry',
age: 21
},
{
name: 'tom',
age: 29
}
]
},
body: {
type: 'each',
source: '${arr}',
items: {
type: 'wrapper',
body: [
{
type: 'tpl',
tpl: "<span class='label label-default m-l-sm'>name: <%= data.name %></span> "
},
{
type: 'tag',
label: 'age: ${age}'
}
]
}
}
})
);
const items = container.querySelectorAll('.cxd-Each .cxd-Wrapper');
expect(items!.length).toBe(2);
expect(items[1]).toHaveTextContent('age: 29');
expect(container).toMatchSnapshot();
});
test('Renderer:Each in form', async () => {
const {container} = render(
amisRender({
type: 'form',
data: {
each: ['A', 'B', 'C']
},
body: [
{
type: 'each',
label: '静态展示each',
name: 'each',
items: {
type: 'tpl',
tpl: "<span class='label label-info m-l-sm'><%= this.item %></span>"
}
}
]
})
);
expect(container.querySelector('.cxd-Form .cxd-Each'));
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,289 @@
import React = require('react');
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
test('Renderer:flex', () => {
const {container} = render(
amisRender(
{
type: 'flex',
items: [
{
style: {
backgroundColor: '#1A5CFF',
width: 100,
height: 50,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#46C93A',
width: 100,
height: 50,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#FF4757',
width: 100,
height: 50,
margin: 5
},
type: 'tpl',
tpl: ''
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:flex justify', () => {
const {container} = render(
amisRender(
{
type: 'page',
body: [
'center',
{
type: 'flex',
justify: 'center',
items: [
{
style: {
backgroundColor: '#1A5CFF',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#46C93A',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#FF4757',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
}
]
},
'flex-start',
{
type: 'flex',
justify: 'flex-start',
items: [
{
style: {
backgroundColor: '#1A5CFF',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#46C93A',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#FF4757',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
}
]
},
'flex-end',
{
type: 'flex',
justify: 'flex-end',
items: [
{
style: {
backgroundColor: '#1A5CFF',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#46C93A',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#FF4757',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
}
]
},
'space-around',
{
type: 'flex',
justify: 'space-around',
items: [
{
style: {
backgroundColor: '#1A5CFF',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
width: 100,
height: 30,
style: {
backgroundColor: '#46C93A',
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#FF4757',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
}
]
},
'space-between',
{
type: 'flex',
justify: 'space-between',
items: [
{
style: {
backgroundColor: '#1A5CFF',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#46C93A',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#FF4757',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
}
]
},
'space-evenly',
{
type: 'flex',
justify: 'space-evenly',
items: [
{
style: {
backgroundColor: '#1A5CFF',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#46C93A',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
},
{
style: {
backgroundColor: '#FF4757',
width: 100,
height: 30,
margin: 5
},
type: 'tpl',
tpl: ''
}
]
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,513 @@
import React from 'react';
import {render, fireEvent, waitFor} from '@testing-library/react';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
import type {RenderOptions} from 'amis-core';
// Mock matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
// Mock DataTransfer API
class MockDataTransferItem {
kind: string;
type: string;
_file: File;
constructor(file: File) {
this.kind = 'file';
this.type = file.type;
this._file = file;
}
getAsFile() {
return this._file;
}
}
class MockDataTransferItemList {
_items: MockDataTransferItem[];
constructor() {
this._items = [];
}
add(file: File) {
const item = new MockDataTransferItem(file);
this._items.push(item);
return item;
}
clear() {
this._items = [];
}
get length() {
return this._items.length;
}
}
class MockDataTransfer {
items: MockDataTransferItemList;
files: File[];
constructor() {
this.items = new MockDataTransferItemList();
this.files = [];
}
add(file: File) {
this.items.add(file);
this.files.push(file);
}
}
// @ts-ignore
global.DataTransfer = MockDataTransfer;
// Mock Excel file data
const mockExcelFile = new File(
[new ArrayBuffer(10)], // Mock binary data
'test.xlsx',
{type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}
);
// Helper function to simulate file upload
const simulateFileUpload = (input: HTMLInputElement, files: File[]) => {
Object.defineProperty(input, 'files', {
value: Object.assign(files, {
item: (index: number) => files[index],
length: files.length
}),
configurable: true
});
fireEvent.change(input);
};
// Mock Excel data for auto-fill test
const mockExcelData = {
excel: [
{
'班级': '1班',
'学号': 1,
'姓名': '张三'
},
{
'班级': '1班',
'学号': 2,
'姓名': '李四'
}
]
};
describe('Renderer:InputExcel', () => {
test('Renderer:InputExcel with basic config', async () => {
const onSubmit = jest.fn();
const {container} = render(
amisRender({
type: 'form',
api: '/api/mock2/form/saveForm',
body: [
{
type: 'input-excel',
name: 'excel'
}
]
}, {
onSubmit
} as RenderOptions, makeEnv())
);
const fileInput = container.querySelector('input[type="file"]') as HTMLInputElement | null;
expect(fileInput).toBeTruthy();
if (!fileInput) {
throw new Error('File input not found');
}
// Simulate file upload
simulateFileUpload(fileInput, [mockExcelFile]);
await waitFor(() => {
// 对于单文件模式,.cxd-ExcelControl-list 元素不存在,检查任何显示
if (container.querySelector('.cxd-ExcelControl-list')) {
expect(container.querySelector('.cxd-ExcelControl-list')).toBeInTheDocument();
} else {
// 单文件模式只检查上传区域存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
}
});
});
test('Renderer:InputExcel with maxLength', async () => {
const onSubmit = jest.fn();
const {container} = render(
amisRender({
type: 'form',
api: '/api/mock2/form/saveForm',
body: [
{
type: 'input-excel',
name: 'excel',
maxLength: 1
}
]
}, {
onSubmit
} as RenderOptions, makeEnv())
);
const input = container.querySelector('input[type="file"]') as HTMLInputElement | null;
expect(input).toBeTruthy();
if (!input) {
throw new Error('File input not found');
}
// Upload first file
simulateFileUpload(input, [mockExcelFile]);
await waitFor(() => {
// 对于单文件模式,.cxd-ExcelControl-list 元素不存在,检查任何显示
if (container.querySelector('.cxd-ExcelControl-list')) {
expect(container.querySelector('.cxd-ExcelControl-list')).toBeInTheDocument();
} else {
// 单文件模式只检查上传区域存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
}
});
});
test('Renderer:InputExcel file removal', async () => {
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
multiple: true
}
],
title: '表单'
})
);
const input = container.querySelector('input[type="file"]') as HTMLInputElement | null;
if (!input) {
throw new Error('File input not found');
}
simulateFileUpload(input, [mockExcelFile]);
await waitFor(() => {
// 对于单文件模式,.cxd-ExcelControl-list 元素不存在,检查任何显示
if (container.querySelector('.cxd-ExcelControl-list')) {
expect(container.querySelector('.cxd-ExcelControl-list')).toBeInTheDocument();
} else {
// 单文件模式只检查上传区域存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
}
});
// 获取删除按钮 (必须指定multiple: true才会显示)
const removeBtn = container.querySelector('.cxd-ExcelControl-clear');
if (removeBtn) {
// 如果找到删除按钮, 则点击它
fireEvent.click(removeBtn);
} else {
// 如果没有删除按钮 (单文件模式), 直接通过onChange触发清空
render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
value: ''
}
],
title: '表单'
})
);
}
// 验证上传区域继续存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
});
test('Renderer:InputExcel with allSheets=true', async () => {
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
allSheets: true
}
]
}, {}, makeEnv())
);
const excelControl = container.querySelector('.cxd-ExcelControl');
expect(excelControl).toBeInTheDocument();
// Upload a file
const input = container.querySelector('input[type="file"]') as HTMLInputElement | null;
if (!input) {
throw new Error('File input not found');
}
simulateFileUpload(input, [mockExcelFile]);
await waitFor(() => {
// 对于单文件模式,.cxd-ExcelControl-list 元素不存在,检查任何显示
if (container.querySelector('.cxd-ExcelControl-list')) {
expect(container.querySelector('.cxd-ExcelControl-list')).toBeInTheDocument();
} else {
// 单文件模式只检查上传区域存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
}
});
});
test('Renderer:InputExcel disabled state', async () => {
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
disabled: true,
multiple: true // 强制使用多文件模式进行测试
}
],
title: '表单'
})
);
const excelControl = container.querySelector('.cxd-ExcelControl');
expect(excelControl).toBeInTheDocument();
// 在多文件模式下, 区域应该包含 is-disabled 类
await waitFor(() => {
const dropzone = container.querySelector('.cxd-ExcelControl-dropzone');
expect(dropzone).toBeInTheDocument();
expect(dropzone?.classList.contains('is-disabled')).toBeTruthy();
});
});
test('Renderer:InputExcel with autoFill', async () => {
const {container} = render(
amisRender({
type: 'form',
data: mockExcelData,
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel'
},
{
type: 'input-text',
name: 'fillClass',
label: 'Class',
value: '${excel[0].班级}'
},
{
type: 'input-text',
name: 'fillName',
label: 'Name',
value: '${excel[0].姓名}'
}
]
}, {}, makeEnv())
);
// Wait for auto-fill to complete
await waitFor(() => {
const classInput = container.querySelector('input[name="fillClass"]') as HTMLInputElement | null;
const nameInput = container.querySelector('input[name="fillName"]') as HTMLInputElement | null;
expect(classInput?.value).toBe('1班');
expect(nameInput?.value).toBe('张三');
});
});
test('Renderer:InputExcel with custom placeholder', async () => {
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
placeholder: 'Custom placeholder text'
}
]
}, {}, makeEnv())
);
const dropzone = container.querySelector('.cxd-ExcelControl-dropzone');
expect(dropzone).toBeInTheDocument();
expect(dropzone?.textContent).toContain('Custom placeholder text');
});
test('Renderer:InputExcel with parseMode=array', async () => {
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
parseMode: 'array'
}
]
}, {}, makeEnv())
);
const excelControl = container.querySelector('.cxd-ExcelControl');
expect(excelControl).toBeInTheDocument();
});
test('Renderer:InputExcel with parseMode=array and includeEmpty=false', async () => {
const onSubmit = jest.fn();
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
parseMode: 'array',
includeEmpty: false
}
],
onSubmit
}, {}, makeEnv())
);
const input = container.querySelector('input[type="file"]') as HTMLInputElement | null;
if (!input) {
throw new Error('File input not found');
}
expect(input).toBeInTheDocument();
// Simulate file upload
simulateFileUpload(input, [mockExcelFile]);
// Wait for file to be processed
await waitFor(() => {
// 对于单文件模式,.cxd-ExcelControl-list 元素不存在,检查任何显示
if (container.querySelector('.cxd-ExcelControl-list')) {
expect(container.querySelector('.cxd-ExcelControl-list')).toBeInTheDocument();
} else {
// 单文件模式只检查上传区域存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
}
});
});
test('Renderer:InputExcel with parseImage=true', async () => {
const onSubmit = jest.fn();
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
label: 'Excel',
parseImage: true,
imageDataURI: true
}
],
onSubmit
}, {}, makeEnv())
);
const input = container.querySelector('input[type="file"]') as HTMLInputElement | null;
if (!input) {
throw new Error('File input not found');
}
expect(input).toBeInTheDocument();
// Simulate file upload
simulateFileUpload(input, [mockExcelFile]);
// Wait for file to be processed
await waitFor(() => {
// 对于单文件模式,.cxd-ExcelControl-list 元素不存在,检查任何显示
if (container.querySelector('.cxd-ExcelControl-list')) {
expect(container.querySelector('.cxd-ExcelControl-list')).toBeInTheDocument();
} else {
// 单文件模式只检查上传区域存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
}
});
});
test('Renderer:InputExcel with maxLength limit', async () => {
const {container} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-excel',
name: 'excel',
maxLength: 1,
multiple: true // 强制使用多文件模式进行测试
}
]
})
);
const input = container.querySelector('input[type="file"]') as HTMLInputElement | null;
if (!input) {
throw new Error('File input not found');
}
simulateFileUpload(input, [mockExcelFile]);
await waitFor(() => {
// 对于单文件模式,.cxd-ExcelControl-list 元素不存在,检查任何显示
if (container.querySelector('.cxd-ExcelControl-list')) {
expect(container.querySelector('.cxd-ExcelControl-list')).toBeInTheDocument();
} else {
// 单文件模式只检查上传区域存在
expect(container.querySelector('.cxd-ExcelControl-dropzone')).toBeInTheDocument();
}
});
// 验证是否达到最大上传数量限制
await waitFor(() => {
const dropzone = container.querySelector('.cxd-ExcelControl-dropzone');
// 在多文件模式, 上传区域应该禁用
if (dropzone?.classList.contains('is-disabled')) {
expect(dropzone?.classList.contains('is-disabled')).toBeTruthy();
} else {
// 允许单文件模式下不添加 is-disabled 类
expect(dropzone).toBeInTheDocument();
}
});
});
});

View File

@@ -0,0 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:array 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="array"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
颜色集合
</span>
</span>
</span>
</label>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Form:options:autoFill:data 1`] = `
{
"a": "a",
"aId": 233,
"aLabel": "OptionA",
"aValue": "a",
}
`;
exports[`Form:options:autoFill:data 2`] = `
{
"a": "b",
"aId": "",
"aLabel": "OptionB",
"aValue": "b",
}
`;
exports[`Form:options:autoFill:multiple:data 1`] = `
{
"a": "a",
"aIds": [
233,
],
"aLabels": [
"OptionA",
],
"aValues": [
"a",
],
}
`;
exports[`Form:options:autoFill:multiple:data 2`] = `
{
"a": "b",
"aIds": [
undefined,
],
"aLabels": [
"OptionB",
],
"aValues": [
"b",
],
}
`;

View File

@@ -0,0 +1,252 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:button 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<i
class="fa fa-plus cxd-Button-icon fa fa-plus"
/>
<span>
Text
</span>
</button>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
OpenDialog
</span>
</button>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal r-2x"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--danger cxd-Button--size-sm"
type="reset"
>
<span>
Reset
</span>
</button>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button 2`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<i
class="fa fa-plus cxd-Button-icon fa fa-plus"
/>
<span>
Text
</span>
</button>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
OpenDialog
</span>
</button>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal r-2x"
data-role="form-item"
>
<button
class="cxd-Button cxd-Button--danger cxd-Button--size-sm"
type="reset"
>
<span>
Reset
</span>
</button>
</div>
</form>
</div>
</div>
<div
class="amis-dialog-widget cxd-Modal cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Modal-overlay in"
/>
<div
class="cxd-Modal-content in"
>
<div
class="cxd-Modal-header"
>
<a
class="cxd-Modal-close"
data-position="left"
data-tooltip="关闭"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Modal-title"
>
提示
</div>
</div>
<div
class="cxd-Modal-body"
role="dialog-body"
>
<span
class="cxd-TplField fr-view"
>
<span>
对,你刚点击了!
</span>
</span>
</div>
<div
class="cxd-Modal-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,680 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:button-group with btnActiveLevel 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="type"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项
</span>
</span>
</span>
</label>
<div
class="cxd-ButtonGroup cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--warning cxd-Button--size-default cxd-ButtonGroup-button--active"
type="button"
>
<span>
Option A
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
Option B
</span>
</button>
<button
class="cxd-Button cxd-Button--light cxd-Button--size-default"
type="button"
>
<span>
Option C
</span>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button-group with tiled 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
多选
</span>
</span>
</span>
</label>
<div
class="cxd-ButtonGroup cxd-ButtonGroup--tiled cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option A
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option B
</span>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button-group with vertical 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
多选
</span>
</span>
</span>
</label>
<div
class="cxd-ButtonGroup cxd-ButtonGroup--vertical cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option A
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option B
</span>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button-group:multiple clearable 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
多选
</span>
</span>
</span>
</label>
<div
class="cxd-ButtonGroup cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default cxd-ButtonGroup-button--active"
type="button"
>
<span>
Option A
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option B
</span>
</button>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
当前值
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
a
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button-group:multiple clearable 2`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
多选
</span>
</span>
</span>
</label>
<div
class="cxd-ButtonGroup cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default cxd-ButtonGroup-button--active"
type="button"
>
<span>
Option A
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default cxd-ButtonGroup-button--active"
type="button"
>
<span>
Option B
</span>
</button>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
当前值
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
a,b
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button-group:multiple clearable 3`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
多选
</span>
</span>
</span>
</label>
<div
class="cxd-ButtonGroup cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default cxd-ButtonGroup-button--active"
type="button"
>
<span>
Option A
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option B
</span>
</button>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
当前值
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
a
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button-group-select 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
单选
</span>
</span>
</span>
</label>
<div
class="cxd-ButtonGroup cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option A
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
Option B
</span>
</button>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
当前值
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
<span
class="text-muted"
>
-
</span>
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,216 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:button-toolbar 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-ButtonToolbar cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
OpenDialog
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="reset"
>
<span>
Reset
</span>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:button-toolbar 2`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-ButtonToolbar cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
OpenDialog
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="reset"
>
<span>
Reset
</span>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div
class="amis-dialog-widget cxd-Modal cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Modal-overlay in"
/>
<div
class="cxd-Modal-content in"
>
<div
class="cxd-Modal-header"
>
<a
class="cxd-Modal-close"
data-position="left"
data-tooltip="关闭"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Modal-title"
>
提示
</div>
</div>
<div
class="cxd-Modal-body"
role="dialog-body"
>
<span
class="cxd-TplField fr-view"
>
<span>
对,你刚点击了!
</span>
</span>
</div>
<div
class="cxd-Modal-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,318 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:chained-select 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-JsonField cxd-Form--debug"
>
<div
class="react-json-view"
style="font-family: monospace; cursor: default; background-color: rgba(0, 0, 0, 0); position: relative;"
>
<div
class="pretty-json-container object-container"
>
<div
class="object-content"
>
<div
class="object-key-val"
>
<span>
<span
style="display: inline-block; cursor: pointer;"
>
<div
class="icon-container"
style="display: inline-block; width: 17px;"
>
<span
class="expanded-icon"
>
<svg
fill="#586e75"
height="1em"
style="vertical-align: middle; color: rgb(88, 110, 117); height: 1em; width: 1em;"
viewBox="0 0 1792 1792"
width="1em"
>
<path
d="M1344 800v64q0 14-9 23t-23 9h-832q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"
/>
</svg>
</span>
</div>
<span />
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54);"
>
{
</span>
</span>
<div
class="object-meta-data"
style="display: inline-block; padding: 0px 0px 0px 10px;"
>
<span
class="object-size"
style="color: rgba(0, 0, 0, 0.3); border-radius: 3px; font-style: italic; margin: 0px 6px 0px 0px; cursor: default;"
>
1
item
</span>
</div>
</span>
<div
class="pushed-content object-container"
>
<div
class="object-content"
style="margin-left: 6px;"
>
<div
class="variable-row"
style="border-left: 1px solid rgb(235, 235, 235); padding: 3px 5px 3px 20px;"
>
<span>
<span
class="object-key"
style="display: inline-block; color: rgb(0, 43, 54); letter-spacing: 0.5px; font-style: none; vertical-align: top; opacity: 0.85;"
>
<span
style="vertical-align: top;"
>
"
</span>
<span
style="display: inline-block;"
>
select3
</span>
<span
style="vertical-align: top;"
>
"
</span>
</span>
<span
style="display: inline-block; margin: 0px 5px; color: rgb(0, 43, 54); vertical-align: top;"
>
:
</span>
</span>
<div
class="variable-value"
style="display: inline-block; padding-right: 6px; position: relative; cursor: default;"
>
<div
style="display: inline-block; color: rgb(203, 75, 22);"
>
<span
class="string-value"
style="cursor: default;"
>
"
a,b
"
</span>
</div>
</div>
</div>
</div>
</div>
<span
class="brace-row"
>
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54); padding-left: 3px;"
>
}
</span>
</span>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="select3"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
级联下拉
</span>
</span>
</span>
</label>
<div
class="cxd-ChainedSelectControl cxd-Form-control"
>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select cxd-Select--inline"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
A 0
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select cxd-Select--inline"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
B 1
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select cxd-Select--inline"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
D 2
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select cxd-Select--inline"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
C 3
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
<div
class="cxd-Spinner in cxd-ChainedSelectControl-spinner"
data-testid="spinner"
>
<div
class="cxd-Spinner-icon cxd-Spinner-icon--sm cxd-Spinner-icon--default"
/>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,289 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:checkbox 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="checkbox"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Checkbox
</span>
</span>
</span>
</label>
<div
class="cxd-CheckboxControl cxd-Form-control is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox--default first last"
data-role="checkbox"
>
<input
type="checkbox"
/>
<i>
<div
class="checkbox-icon icon"
/>
</i>
<span
class=""
>
<span
class="cxd-TplField fr-view"
>
<span>
选项说明
</span>
</span>
</span>
</label>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:checkbox with checked 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="checkbox"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Checkbox
</span>
</span>
</span>
</label>
<div
class="cxd-CheckboxControl cxd-Form-control is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox--default first last checked cxd-Checkbox--checkbox--default--checked"
data-role="checkbox"
>
<input
checked=""
type="checkbox"
/>
<i>
<div
class="checkbox-icon icon"
/>
</i>
<span
class=""
>
<span
class="cxd-TplField fr-view"
>
<span>
选项说明
</span>
</span>
</span>
</label>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:checkbox with optionType 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="checkbox"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Checkbox
</span>
</span>
</span>
</label>
<div
class="cxd-CheckboxControl cxd-Form-control is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox--button first last checked cxd-Checkbox--checkbox--button--checked"
data-role="checkbox"
>
<input
type="checkbox"
/>
<i>
<div
class="checkbox-icon icon"
/>
</i>
<span
class=""
>
<span
class="cxd-TplField fr-view"
>
<span>
去吃饭
</span>
</span>
</span>
</label>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="checkbox"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
您吃了吗
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
吃了
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:condition-builder 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="conditions"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
条件组件
</span>
</span>
</span>
</label>
<div
class="cxd-ConditionBuilderControl cxd-Form-control"
>
<div
class="cxd-CBGroup"
>
<div
class="cxd-CBGroup-toolbarCondition"
draggable="true"
>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
且
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
</div>
<div
class="cxd-CBGroup-body-wrapper"
>
<div
class="cxd-CBGroup-body"
>
<div
class="cxd-CBGroup-placeholder "
>
空
</div>
</div>
<div
class="cxd-CBGroup-toolbar"
draggable="true"
>
<div
class="cxd-CBGroup-toolbarConditionAdd"
>
<div
class="cxd-ButtonGroup"
>
<button
class="cxd-Button cxd-Button--link cxd-Button--size-xs"
type="button"
>
添加条件
</button>
<button
class="cxd-Button cxd-Button--link cxd-Button--size-xs"
type="button"
>
添加条件组
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<span
class="cxd-TplField fr-view cxd-Form-description"
>
<span>
适合让用户自己拼查询条件,然后后端根据数据生成 query where
</span>
</span>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,106 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:container 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal no-border"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
container
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Container"
data-role="container"
>
<div
class="cxd-Container-body bg-white"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="text"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl cxd-TextControl--withAddOn"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
<div
class="cxd-TextControl-button"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
按钮
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,90 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:datetime 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
date
</span>
</span>
</span>
</label>
<div
class="cxd-DateControl is-datetime cxd-Form-control"
>
<div
class="cxd-DatePicker"
tabindex="0"
>
<input
autocomplete="off"
class="cxd-DatePicker-input"
placeholder="请选择日期以及时间"
type="text"
value="2019-06-06 21:11:00"
/>
<a
class="cxd-DatePicker-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<a
class="cxd-DatePicker-toggler"
>
<icon-mock
classname="icon icon-date"
icon="date"
/>
</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,667 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:fieldSet 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<fieldset
class="cxd-Collapse is-active no-border"
>
<legend
class="cxd-Collapse-header bg-dark noTitle"
>
<span
class="cxd-Collapse-arrow-wrap"
>
<icon-mock
classname="cxd-Collapse-arrow icon icon-right-arrow-bold cxd-Collapse-arrow"
icon="right-arrow-bold"
/>
</span>
</legend>
<div
class="cxd-Collapse-contentWrapper"
>
<div
class="cxd-Collapse-body bg-white"
>
<div
class="cxd-Collapse-content"
>
<div
class="cxd-Form--horizontal"
>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="text"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span />
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:fieldSet with mode 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<fieldset
class="cxd-Collapse is-active"
>
<legend
class="cxd-Collapse-header noTitle"
/>
<div
class="cxd-Collapse-contentWrapper"
>
<div
class="cxd-Collapse-body"
>
<div
class="cxd-Collapse-content"
>
<div
class="cxd-Form--horizontal"
>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="text1"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本1
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text1"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="text2"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本2
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text2"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:fieldSet with mode 2`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<fieldset
class="cxd-Collapse is-active"
>
<legend
class="cxd-Collapse-header noTitle"
/>
<div
class="cxd-Collapse-contentWrapper"
>
<div
class="cxd-Collapse-body"
>
<div
class="cxd-Collapse-content"
>
<div
class="cxd-Form--inline"
>
<div
class="cxd-Form-item cxd-Form-item--inline"
data-amis-name="text1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本1
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text1"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--inline"
data-amis-name="text2"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本2
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text2"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:fieldSet with mode 3`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<fieldset
class="cxd-Collapse is-active"
>
<legend
class="cxd-Collapse-header noTitle"
/>
<div
class="cxd-Collapse-contentWrapper"
>
<div
class="cxd-Collapse-body"
>
<div
class="cxd-Collapse-content"
>
<div
class="cxd-Form--justify"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="text1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本1
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text1"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="text2"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本2
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text2"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:fieldSet with titlePosition & collapseTitle & title 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<fieldset
class="cxd-Collapse is-active cxd-Collapse--title-bottom"
>
<div
class="cxd-Collapse-contentWrapper"
>
<div
class="cxd-Collapse-body"
>
<div
class="cxd-Collapse-content"
>
<div
class="cxd-Form--normal"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="text1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本1
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text1"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="text2"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本2
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text2"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Collapse-header"
>
<span
class="cxd-Collapse-arrow-wrap"
>
<icon-mock
classname="cxd-Collapse-arrow icon icon-right-arrow-bold cxd-Collapse-arrow"
icon="right-arrow-bold"
/>
</span>
<span
class="cxd-TplField fr-view"
>
<span>
收起设置
</span>
</span>
</div>
</fieldset>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,313 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:FormItem:validateApi:failed 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal is-error is-required has-error--isRequired"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
<span
class="cxd-Form-star"
>
*
</span>
</span>
</label>
<div
class="cxd-Form-control is-error has-error--isRequired cxd-TextControl is-focused"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
<ul
class="cxd-Form-feedback"
>
<li>
这是必填项
</li>
</ul>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:FormItem:validateApi:failed 2`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal is-error is-required"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
<span
class="cxd-Form-star"
>
*
</span>
</span>
</label>
<div
class="cxd-Form-control is-error cxd-TextControl is-focused"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value="123"
/>
</div>
</div>
<ul
class="cxd-Form-feedback"
>
<li>
用户名已存在
</li>
</ul>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:FormItem:validateApi:success 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal is-error is-required has-error--isRequired"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
<span
class="cxd-Form-star"
>
*
</span>
</span>
</label>
<div
class="cxd-Form-control is-error has-error--isRequired cxd-TextControl is-focused"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
<ul
class="cxd-Form-feedback"
>
<li>
这是必填项
</li>
</ul>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:FormItem:validateApi:success 2`] = `
{
"a": "123",
}
`;

View File

@@ -0,0 +1,447 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:formula 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
a
</span>
</span>
</span>
</label>
<div
class="cxd-NumberControl cxd-Form-control"
>
<div
class="cxd-Number cxd-Number--borderFull"
>
<div
class="cxd-Number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="cxd-Number-handler cxd-Number-handler-up"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-up-inner"
unselectable="on"
/>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="cxd-Number-handler cxd-Number-handler-down"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-down-inner"
unselectable="on"
/>
</span>
</div>
<div
class="cxd-Number-input-wrap"
>
<input
aria-valuenow="1"
autocomplete="off"
class="cxd-Number-input"
name="a"
role="spinbutton"
step="1"
value="1"
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="b"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
b
</span>
</span>
</span>
</label>
<div
class="cxd-NumberControl cxd-Form-control"
>
<div
class="cxd-Number cxd-Number--borderFull"
>
<div
class="cxd-Number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="cxd-Number-handler cxd-Number-handler-up"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-up-inner"
unselectable="on"
/>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="cxd-Number-handler cxd-Number-handler-down"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-down-inner"
unselectable="on"
/>
</span>
</div>
<div
class="cxd-Number-input-wrap"
>
<input
aria-valuenow="2"
autocomplete="off"
class="cxd-Number-input"
name="b"
role="spinbutton"
step="1"
value="2"
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="sum1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
sum1
</span>
</span>
</span>
</label>
<div
class="cxd-NumberControl cxd-Form-control"
>
<div
class="cxd-Number cxd-Number--borderFull"
>
<div
class="cxd-Number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="cxd-Number-handler cxd-Number-handler-up"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-up-inner"
unselectable="on"
/>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="cxd-Number-handler cxd-Number-handler-down"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-down-inner"
unselectable="on"
/>
</span>
</div>
<div
class="cxd-Number-input-wrap"
>
<input
aria-valuenow="3"
autocomplete="off"
class="cxd-Number-input"
name="sum1"
role="spinbutton"
step="1"
value="3"
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="sum2"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
sum2
</span>
</span>
</span>
</label>
<div
class="cxd-NumberControl cxd-Form-control"
>
<div
class="cxd-Number cxd-Number--borderFull"
>
<div
class="cxd-Number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="cxd-Number-handler cxd-Number-handler-up"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-up-inner"
unselectable="on"
/>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="cxd-Number-handler cxd-Number-handler-down"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-down-inner"
unselectable="on"
/>
</span>
</div>
<div
class="cxd-Number-input-wrap"
>
<input
aria-valuenow="4"
autocomplete="off"
class="cxd-Number-input"
name="sum2"
role="spinbutton"
step="1"
value="4"
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="sum3"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
sum3
</span>
</span>
</span>
</label>
<div
class="cxd-NumberControl cxd-Form-control"
>
<div
class="cxd-Number cxd-Number--borderFull"
>
<div
class="cxd-Number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="cxd-Number-handler cxd-Number-handler-up"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-up-inner"
unselectable="on"
/>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="cxd-Number-handler cxd-Number-handler-down"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-down-inner"
unselectable="on"
/>
</span>
</div>
<div
class="cxd-Number-input-wrap"
>
<input
aria-valuenow="5"
autocomplete="off"
class="cxd-Number-input"
name="sum3"
role="spinbutton"
step="1"
value="5"
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="sum4"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
sum4
</span>
</span>
</span>
</label>
<div
class="cxd-NumberControl cxd-Form-control"
>
<div
class="cxd-Number cxd-Number--borderFull"
>
<div
class="cxd-Number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="cxd-Number-handler cxd-Number-handler-up"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-up-inner"
unselectable="on"
/>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="cxd-Number-handler cxd-Number-handler-down"
role="button"
unselectable="on"
>
<span
class="cxd-Number-handler-down-inner"
unselectable="on"
/>
</span>
</div>
<div
class="cxd-Number-input-wrap"
>
<input
aria-valuenow="5"
autocomplete="off"
class="cxd-Number-input"
name="sum4"
role="spinbutton"
step="1"
value="5"
/>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,87 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:hbox 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-Grid"
data-role="container"
>
<div
class="cxd-Grid-col--md3 bg-white"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="text"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text"
placeholder="Text"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Grid-col--md9"
>
<span
class="cxd-TplField fr-view"
>
<span>
其他渲染器类型
</span>
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,291 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:group 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-group cxd-Form-group--hor cxd-Form-group--horizontal bg-white"
>
<div
class="cxd-Form-groupColumn"
>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="test1"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--0"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value cxd-Form-itemColumn--10"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test1"
placeholder="Placeholder"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-groupColumn"
>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="test2"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--0"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value cxd-Form-itemColumn--10"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test2"
placeholder="Placeholder"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-group cxd-Form-group--hor cxd-Form-group--inline bg-white"
>
<div
class="cxd-Form-item cxd-Form-item--inline"
data-amis-name="test1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test1"
placeholder="Placeholder"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--inline"
data-amis-name="test2"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test2"
placeholder="Placeholder"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-group cxd-Form-group--ver cxd-Form-group--normal"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test1"
placeholder="Placeholder"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test2"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test2"
placeholder="Placeholder"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,86 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:hbox 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-Hbox cxd-Hbox--xs"
>
<div
class="cxd-Hbox-col w-sm"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="text"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text"
placeholder="Text"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Hbox-col"
>
<span
class="cxd-TplField fr-view"
>
<span>
其他类型的渲染器
</span>
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,89 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:icon-picker 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
icon-picker
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-IconPickerControl"
>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-IconPickerControl-input cxd-IconPickerControl-input--withAC"
role="combobox"
>
<div
class="cxd-IconPickerControl-valueWrap"
>
<div
class="cxd-IconPickerControl-value"
>
<i
class="glyphicon glyphicon-plus"
/>
glyphicon glyphicon-plus
</div>
<input
aria-autocomplete="list"
autocomplete="off"
id="downshift-0-input"
name="a"
size="10"
value=""
/>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,401 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Form:initData 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value="1"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="b"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="b"
placeholder=""
size="10"
type="text"
value="2"
/>
</div>
</div>
</div>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</form>
</div>
`;
exports[`Form:initData 2`] = `
{
"a": "1",
"b": "2",
}
`;
exports[`Form:initData:remote 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value="1"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="c"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
Label
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="c"
placeholder=""
size="10"
type="text"
value="123"
/>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Form:initData:remote 2`] = `
{
"config": {
"cancelExecutor": [Function],
"errorMessage": "fetchFailed",
"onSuccess": [Function],
"successMessage": undefined,
},
"context": {
"c": "123",
},
"method": "get",
"query": {
"c": "123",
},
"url": "/api/xxx?c=123",
}
`;
exports[`Form:initData:remote 3`] = `
{
"a": 1,
"b": 2,
"c": "123",
}
`;
exports[`Form:initData:super 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value="1"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="b"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="b"
placeholder=""
size="10"
type="text"
value="2"
/>
</div>
</div>
</div>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</form>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Form:initData:without-super 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="b"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="b"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</form>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Form:initData:without-super 2`] = `{}`;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,795 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:inputCity 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--horizontal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="city"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
城市
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-CityPicker"
>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
北京市
</div>
</div>
<a
class="cxd-Select-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
北京市市辖区
</div>
</div>
<a
class="cxd-Select-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select is-focused"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
海淀区
</div>
</div>
<a
class="cxd-Select-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:inputCity with searchable: open select 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--horizontal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="city"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
城市
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-CityPicker"
>
<div
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="downshift-3-menu"
class="cxd-Select cxd-Select--searchable is-opened has-popover"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-placeholder"
>
请选择
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
<div
class="cxd-PopOver cxd-Select-popover"
role="popover"
style="display: block; width: auto; left: 0px; top: 0px; visibility: hidden;"
theme="cxd"
>
<div
class="cxd-PopOver-overlay"
/>
<div
class="cxd-Select-menu"
>
<div
class="cxd-Select-input"
>
<icon-mock
classname="icon icon-search"
icon="search"
/>
<input
aria-autocomplete="list"
aria-controls="downshift-3-menu"
autocomplete="off"
id="downshift-3-input"
placeholder="搜索"
type="text"
value=""
/>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-0"
role="option"
>
<span
class="cxd-Select-option-content"
title="北京市"
>
北京市
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-1"
role="option"
>
<span
class="cxd-Select-option-content"
title="天津市"
>
天津市
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-2"
role="option"
>
<span
class="cxd-Select-option-content"
title="河北省"
>
河北省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-3"
role="option"
>
<span
class="cxd-Select-option-content"
title="山西省"
>
山西省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-4"
role="option"
>
<span
class="cxd-Select-option-content"
title="内蒙古自治区"
>
内蒙古自治区
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-5"
role="option"
>
<span
class="cxd-Select-option-content"
title="辽宁省"
>
辽宁省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-6"
role="option"
>
<span
class="cxd-Select-option-content"
title="吉林省"
>
吉林省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-7"
role="option"
>
<span
class="cxd-Select-option-content"
title="黑龙江省"
>
黑龙江省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-8"
role="option"
>
<span
class="cxd-Select-option-content"
title="上海市"
>
上海市
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-9"
role="option"
>
<span
class="cxd-Select-option-content"
title="江苏省"
>
江苏省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-10"
role="option"
>
<span
class="cxd-Select-option-content"
title="浙江省"
>
浙江省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-11"
role="option"
>
<span
class="cxd-Select-option-content"
title="安徽省"
>
安徽省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-12"
role="option"
>
<span
class="cxd-Select-option-content"
title="福建省"
>
福建省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-13"
role="option"
>
<span
class="cxd-Select-option-content"
title="江西省"
>
江西省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-14"
role="option"
>
<span
class="cxd-Select-option-content"
title="山东省"
>
山东省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-15"
role="option"
>
<span
class="cxd-Select-option-content"
title="河南省"
>
河南省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-16"
role="option"
>
<span
class="cxd-Select-option-content"
title="湖北省"
>
湖北省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-17"
role="option"
>
<span
class="cxd-Select-option-content"
title="湖南省"
>
湖南省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-18"
role="option"
>
<span
class="cxd-Select-option-content"
title="广东省"
>
广东省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-19"
role="option"
>
<span
class="cxd-Select-option-content"
title="广西壮族自治区"
>
广西壮族自治区
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-20"
role="option"
>
<span
class="cxd-Select-option-content"
title="海南省"
>
海南省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-21"
role="option"
>
<span
class="cxd-Select-option-content"
title="重庆市"
>
重庆市
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-22"
role="option"
>
<span
class="cxd-Select-option-content"
title="四川省"
>
四川省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-23"
role="option"
>
<span
class="cxd-Select-option-content"
title="贵州省"
>
贵州省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-24"
role="option"
>
<span
class="cxd-Select-option-content"
title="云南省"
>
云南省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-25"
role="option"
>
<span
class="cxd-Select-option-content"
title="西藏自治区"
>
西藏自治区
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-26"
role="option"
>
<span
class="cxd-Select-option-content"
title="陕西省"
>
陕西省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-27"
role="option"
>
<span
class="cxd-Select-option-content"
title="甘肃省"
>
甘肃省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-28"
role="option"
>
<span
class="cxd-Select-option-content"
title="青海省"
>
青海省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-29"
role="option"
>
<span
class="cxd-Select-option-content"
title="宁夏回族自治区"
>
宁夏回族自治区
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-30"
role="option"
>
<span
class="cxd-Select-option-content"
title="新疆维吾尔自治区"
>
新疆维吾尔自治区
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-31"
role="option"
>
<span
class="cxd-Select-option-content"
title="台湾省"
>
台湾省
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-32"
role="option"
>
<span
class="cxd-Select-option-content"
title="香港特别行政区"
>
香港特别行政区
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-3-item-33"
role="option"
>
<span
class="cxd-Select-option-content"
title="澳门特别行政区"
>
澳门特别行政区
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,749 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:inputDate 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
date
</span>
</span>
</span>
</label>
<div
class="cxd-DateControl is-date cxd-Form-control"
>
<div
class="cxd-DatePicker"
tabindex="0"
>
<input
autocomplete="off"
class="cxd-DatePicker-input"
placeholder="请选择日期"
type="text"
value="2019-06-07"
/>
<a
class="cxd-DatePicker-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<a
class="cxd-DatePicker-toggler"
>
<icon-mock
classname="icon icon-date"
icon="date"
/>
</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:inputDate compatible with format & inputFormat 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--horizontal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date1"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
日期
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-DateControl is-date cxd-Form-control"
>
<div
class="cxd-DatePicker"
tabindex="0"
>
<input
autocomplete="off"
class="cxd-DatePicker-input"
placeholder="请选择日期"
type="text"
value="19/08-2022"
/>
<a
class="cxd-DatePicker-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<a
class="cxd-DatePicker-toggler"
>
<icon-mock
classname="icon icon-date"
icon="date"
/>
</a>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date1"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span />
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
今天是2022年, 08月, 19日
</span>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date2"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
日期
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-DateControl is-date cxd-Form-control"
>
<div
class="cxd-DatePicker"
tabindex="0"
>
<input
autocomplete="off"
class="cxd-DatePicker-input"
placeholder="请选择日期"
type="text"
value="19/08-2022"
/>
<a
class="cxd-DatePicker-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<a
class="cxd-DatePicker-toggler"
>
<icon-mock
classname="icon icon-date"
icon="date"
/>
</a>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date2"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span />
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
今天是2022年, 08月, 19日
</span>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:inputDate with clearable: clearable false 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--horizontal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
日期
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-DateControl is-date cxd-Form-control"
>
<div
class="cxd-DatePicker"
tabindex="0"
>
<input
autocomplete="off"
class="cxd-DatePicker-input"
placeholder="请选择日期"
type="text"
value="2022-08-19"
/>
<a
class="cxd-DatePicker-toggler"
>
<icon-mock
classname="icon icon-date"
icon="date"
/>
</a>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:inputDate with clearable: clearable true 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--horizontal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
日期
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-DateControl is-date cxd-Form-control"
>
<div
class="cxd-DatePicker"
tabindex="0"
>
<input
autocomplete="off"
class="cxd-DatePicker-input"
placeholder="请选择日期"
type="text"
value=""
/>
<a
class="cxd-DatePicker-toggler"
>
<icon-mock
classname="icon icon-date"
icon="date"
/>
</a>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span />
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
<span
class="text-muted"
>
-
</span>
</span>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:inputDate with valueFormat & displayFormat 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--horizontal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
日期
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-DateControl is-date cxd-Form-control"
>
<div
class="cxd-DatePicker"
tabindex="0"
>
<input
autocomplete="off"
class="cxd-DatePicker-input"
placeholder="请选择日期"
type="text"
value="19/08-2022"
/>
<a
class="cxd-DatePicker-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<a
class="cxd-DatePicker-toggler"
>
<icon-mock
classname="icon icon-date"
icon="date"
/>
</a>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="date"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span />
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
今天是2022年, 08月, 19日
</span>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,570 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:input-formula button 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-JsonField cxd-Form--debug"
>
<div
class="react-json-view"
style="font-family: monospace; cursor: default; background-color: rgba(0, 0, 0, 0); position: relative;"
>
<div
class="pretty-json-container object-container"
>
<div
class="object-content"
>
<div
class="object-key-val"
>
<span>
<span
style="display: inline-block; cursor: pointer;"
>
<div
class="icon-container"
style="display: inline-block; width: 17px;"
>
<span
class="expanded-icon"
>
<svg
fill="#586e75"
height="1em"
style="vertical-align: middle; color: rgb(88, 110, 117); height: 1em; width: 1em;"
viewBox="0 0 1792 1792"
width="1em"
>
<path
d="M1344 800v64q0 14-9 23t-23 9h-832q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"
/>
</svg>
</span>
</div>
<span />
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54);"
>
{
</span>
</span>
<div
class="object-meta-data"
style="display: inline-block; padding: 0px 0px 0px 10px;"
>
<span
class="object-size"
style="color: rgba(0, 0, 0, 0.3); border-radius: 3px; font-style: italic; margin: 0px 6px 0px 0px; cursor: default;"
>
1
item
</span>
</div>
</span>
<div
class="pushed-content object-container"
>
<div
class="object-content"
style="margin-left: 6px;"
>
<div
class="variable-row"
style="border-left: 1px solid rgb(235, 235, 235); padding: 3px 5px 3px 20px;"
>
<span>
<span
class="object-key"
style="display: inline-block; color: rgb(0, 43, 54); letter-spacing: 0.5px; font-style: none; vertical-align: top; opacity: 0.85;"
>
<span
style="vertical-align: top;"
>
"
</span>
<span
style="display: inline-block;"
>
formula
</span>
<span
style="vertical-align: top;"
>
"
</span>
</span>
<span
style="display: inline-block; margin: 0px 5px; color: rgb(0, 43, 54); vertical-align: top;"
>
:
</span>
</span>
<div
class="variable-value"
style="display: inline-block; padding-right: 6px; position: relative; cursor: default;"
>
<div
style="display: inline-block; color: rgb(203, 75, 22);"
>
<span
class="string-value"
style="cursor: default;"
>
"
SUM(1 + 2)
"
</span>
</div>
</div>
</div>
</div>
</div>
<span
class="brace-row"
>
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54); padding-left: 3px;"
>
}
</span>
</span>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="formula"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
公式
</span>
</span>
</span>
</label>
<div
class="cxd-FormulaPicker cxd-FormulaPicker--text cxd-Form-control"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default is-active cxd-FormulaPicker-action w-full"
type="button"
>
<span
class="cxd-FormulaPicker-label"
>
公式编辑
</span>
</button>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:input-formula input-group 1`] = `
<div>
<div
class="cxd-Page"
>
<div
class="cxd-Page-content"
>
<div
class="cxd-Page-main"
>
<div
class="cxd-Page-body"
role="page-body"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-JsonField cxd-Form--debug"
>
<div
class="react-json-view"
style="font-family: monospace; cursor: default; background-color: rgba(0, 0, 0, 0); position: relative;"
>
<div
class="pretty-json-container object-container"
>
<div
class="object-content"
>
<div
class="object-key-val"
>
<span>
<span
style="display: inline-block; cursor: pointer;"
>
<div
class="icon-container"
style="display: inline-block; width: 17px;"
>
<span
class="expanded-icon"
>
<svg
fill="#586e75"
height="1em"
style="vertical-align: middle; color: rgb(88, 110, 117); height: 1em; width: 1em;"
viewBox="0 0 1792 1792"
width="1em"
>
<path
d="M1344 800v64q0 14-9 23t-23 9h-832q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"
/>
</svg>
</span>
</div>
<span />
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54);"
>
{
</span>
</span>
<div
class="object-meta-data"
style="display: inline-block; padding: 0px 0px 0px 10px;"
>
<span
class="object-size"
style="color: rgba(0, 0, 0, 0.3); border-radius: 3px; font-style: italic; margin: 0px 6px 0px 0px; cursor: default;"
>
1
item
</span>
</div>
</span>
<div
class="pushed-content object-container"
>
<div
class="object-content"
style="margin-left: 6px;"
>
<div
class="variable-row"
style="border-left: 1px solid rgb(235, 235, 235); padding: 3px 5px 3px 20px;"
>
<span>
<span
class="object-key"
style="display: inline-block; color: rgb(0, 43, 54); letter-spacing: 0.5px; font-style: none; vertical-align: top; opacity: 0.85;"
>
<span
style="vertical-align: top;"
>
"
</span>
<span
style="display: inline-block;"
>
formula
</span>
<span
style="vertical-align: top;"
>
"
</span>
</span>
<span
style="display: inline-block; margin: 0px 5px; color: rgb(0, 43, 54); vertical-align: top;"
>
:
</span>
</span>
<div
class="variable-value"
style="display: inline-block; padding-right: 6px; position: relative; cursor: default;"
>
<div
style="display: inline-block; color: rgb(203, 75, 22);"
>
<span
class="string-value"
style="cursor: default;"
>
"
SUM(1 + 2)
"
</span>
</div>
</div>
</div>
</div>
</div>
<span
class="brace-row"
>
<span
style="display: inline-block; cursor: pointer; font-weight: bold; color: rgb(0, 43, 54); padding-left: 3px;"
>
}
</span>
</span>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="formula"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
公式
</span>
</span>
</span>
</label>
<div
class="cxd-FormulaPicker is-input-group cxd-FormulaPicker--text cxd-Form-control"
>
<div
class="cxd-InputBox cxd-FormulaPicker-input cxd-InputBox--borderFull"
>
<div
class="cxd-FormulaCodeEditor cxd-FormulaCodeEditor--singleLine"
>
<div
class="CodeMirror cm-s-idea"
translate="no"
>
<div
style="overflow: hidden; position: relative; width: 3px; height: 0px;"
>
<textarea
autocapitalize="off"
autocorrect="off"
spellcheck="false"
style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"
tabindex="0"
/>
</div>
<div
class="CodeMirror-scrollbar-filler"
cm-not-content="true"
/>
<div
class="CodeMirror-gutter-filler"
cm-not-content="true"
/>
<div
class="CodeMirror-scroll"
tabindex="-1"
>
<div
class="CodeMirror-sizer"
style="margin-left: 0px; min-width: 3px;"
>
<div
style="position: relative;"
>
<div
class="CodeMirror-lines"
role="presentation"
>
<div
role="presentation"
style="position: relative; outline: none;"
>
<div
class="CodeMirror-measure"
/>
<div
class="CodeMirror-measure"
>
<pre
class="CodeMirror-line"
role="presentation"
>
<span
role="presentation"
style="padding-right: .1px;"
>
SUM(1 + 2)
</span>
</pre>
</div>
<div
style="position: relative; z-index: 1;"
/>
<div
class="CodeMirror-cursors"
/>
<div
class="CodeMirror-code"
role="presentation"
/>
</div>
</div>
</div>
</div>
<div
style="position: absolute; height: 50px; width: 1px;"
/>
<div
class="CodeMirror-gutters"
style="display: none;"
/>
</div>
</div>
</div>
<a
class="cxd-InputBox-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
</div>
<a
class="cxd-FormulaPicker-toggler"
>
<icon-mock
classname="icon icon-function"
icon="function"
/>
</a>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,79 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:InputGroup 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal no-border"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
input-group
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-InputGroup cxd-InputGroup-validation--full cxd-Form-control"
>
<div
class="cxd-TextControl-input cxd-Form-control"
>
<input
autocomplete="off"
class=""
name="text"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,394 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:inputMonthRange with embed 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
The form
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
月份范围
</span>
</span>
</span>
</label>
<div
class="cxd-DateRangeControl cxd-Form-control"
>
<div
class="cxd-DateRangeCalendar"
>
<div
class="cxd-DateRangePicker-wrap"
>
<ul
class="cxd-DateRangePicker-rangers"
>
<li
class="cxd-DateRangePicker-ranger"
>
<a>
这个月
</a>
</li>
<li
class="cxd-DateRangePicker-ranger"
>
<a>
上个月
</a>
</li>
</ul>
<div
class="cxd-DateRangePicker-picker-wrap is-vertical"
>
<div
class="rdt rdtStatic rdtOpen cxd-DateRangePicker-start"
>
<div
class="rdtPicker rdtPickerDate"
>
<div
class="rdtMonths"
>
<table
class="headerTable"
>
<thead>
<tr>
<th
class="rdtPrev"
>
«
</th>
<th
class="rdtSwitch"
>
2019年
</th>
<th
class="rdtNext"
>
»
</th>
</tr>
</thead>
</table>
<table>
<tbody>
<tr>
<td
class="rdtMonth"
data-value="0"
>
<span>
1月
</span>
</td>
<td
class="rdtMonth"
data-value="1"
>
<span>
2月
</span>
</td>
<td
class="rdtMonth"
data-value="2"
>
<span>
3月
</span>
</td>
</tr>
<tr>
<td
class="rdtMonth"
data-value="3"
>
<span>
4月
</span>
</td>
<td
class="rdtMonth"
data-value="4"
>
<span>
5月
</span>
</td>
<td
class="rdtMonth"
data-value="5"
>
<span>
6月
</span>
</td>
</tr>
<tr>
<td
class="rdtMonth"
data-value="6"
>
<span>
7月
</span>
</td>
<td
class="rdtMonth"
data-value="7"
>
<span>
8月
</span>
</td>
<td
class="rdtMonth"
data-value="8"
>
<span>
9月
</span>
</td>
</tr>
<tr>
<td
class="rdtMonth rdtBetween rdtActive rdtStart"
data-value="9"
>
<span>
10月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="10"
>
<span>
11月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="11"
>
<span>
12月
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class="rdt rdtStatic rdtOpen cxd-DateRangePicker-end"
>
<div
class="rdtPicker rdtPickerDate"
>
<div
class="rdtMonths"
>
<table
class="headerTable"
>
<thead>
<tr>
<th
class="rdtPrev"
>
«
</th>
<th
class="rdtSwitch"
>
2022年
</th>
<th
class="rdtNext"
>
»
</th>
</tr>
</thead>
</table>
<table>
<tbody>
<tr>
<td
class="rdtMonth rdtBetween"
data-value="0"
>
<span>
1月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="1"
>
<span>
2月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="2"
>
<span>
3月
</span>
</td>
</tr>
<tr>
<td
class="rdtMonth rdtBetween"
data-value="3"
>
<span>
4月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="4"
>
<span>
5月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="5"
>
<span>
6月
</span>
</td>
</tr>
<tr>
<td
class="rdtMonth rdtBetween"
data-value="6"
>
<span>
7月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="7"
>
<span>
8月
</span>
</td>
<td
class="rdtMonth rdtBetween"
data-value="8"
>
<span>
9月
</span>
</td>
</tr>
<tr>
<td
class="rdtMonth rdtBetween"
data-value="9"
>
<span>
10月
</span>
</td>
<td
class="rdtMonth rdtBetween rdtActive rdtEnd"
data-value="10"
>
<span>
11月
</span>
</td>
<td
class="rdtMonth is-disabled"
data-value="11"
>
<span>
12月
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,262 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:InputQuarterRange with embed 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
季度范围
</span>
</span>
</span>
</label>
<div
class="cxd-DateRangeControl cxd-Form-control"
>
<div
class="cxd-DateRangeCalendar"
>
<div
class="cxd-DateRangePicker-wrap"
>
<ul
class="cxd-DateRangePicker-rangers"
>
<li
class="cxd-DateRangePicker-ranger"
>
<a>
这个季度
</a>
</li>
<li
class="cxd-DateRangePicker-ranger"
>
<a>
上个季度
</a>
</li>
</ul>
<div
class="cxd-DateRangePicker-picker-wrap is-vertical"
>
<div
class="rdt rdtStatic rdtOpen cxd-DateRangePicker-start"
>
<div
class="rdtPicker rdtPickerDate"
>
<div
class="cxd-ClalendarQuarter"
>
<table>
<thead>
<tr>
<th
class="rdtPrev"
>
«
</th>
<th
class="rdtSwitch"
>
2021年
</th>
<th
class="rdtNext"
>
»
</th>
</tr>
</thead>
</table>
<table>
<tbody>
<tr>
<td
class="rdtQuarter"
data-value="1"
>
<span>
Q
1
</span>
</td>
<td
class="rdtQuarter"
data-value="2"
>
<span>
Q
2
</span>
</td>
</tr>
<tr>
<td
class="rdtQuarter"
data-value="3"
>
<span>
Q
3
</span>
</td>
<td
class="rdtQuarter rdtBetween rdtActive rdtStart rdtActive rdtEnd"
data-value="4"
>
<span>
Q
4
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class="rdt rdtStatic rdtOpen cxd-DateRangePicker-end"
>
<div
class="rdtPicker rdtPickerDate"
>
<div
class="cxd-ClalendarQuarter"
>
<table>
<thead>
<tr>
<th
class="rdtPrev"
>
«
</th>
<th
class="rdtSwitch"
>
2021年
</th>
<th
class="rdtNext"
>
»
</th>
</tr>
</thead>
</table>
<table>
<tbody>
<tr>
<td
class="rdtQuarter rdtDisabled"
data-value="1"
>
<span>
Q
1
</span>
</td>
<td
class="rdtQuarter rdtDisabled"
data-value="2"
>
<span>
Q
2
</span>
</td>
</tr>
<tr>
<td
class="rdtQuarter rdtDisabled"
data-value="3"
>
<span>
Q
3
</span>
</td>
<td
class="rdtQuarter rdtBetween rdtActive rdtStart rdtActive rdtEnd"
data-value="4"
>
<span>
Q
4
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,783 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:InputSubForm base 1`] = `
<body
class="is-modalOpened"
style="width: calc(100% - 0px);"
>
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="form"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
子Form
</span>
</span>
</span>
</label>
<div
class="cxd-SubFormControl cxd-Form-control"
>
<div
class="cxd-SubForm-values"
>
<div
class="cxd-SubForm-value"
data-position="bottom"
data-tooltip="编辑详情"
>
<span
class="cxd-SubForm-valueLabel"
>
<span
class="cxd-TplField fr-view"
>
<span>
设置子表单
</span>
</span>
</span>
<a
class="cxd-SubForm-valueEdit"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
<div
class="amis-dialog-widget cxd-Modal cxd-Modal--1th"
role="dialog"
>
<div
class="cxd-Modal-overlay in"
/>
<div
class="cxd-Modal-content in"
>
<div
class="cxd-Modal-header"
>
<a
class="cxd-Modal-close"
data-position="left"
data-tooltip="关闭"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
<div
class="cxd-Modal-title"
>
配置子表单
</div>
</div>
<div
class="cxd-Modal-body"
role="dialog-body"
>
<div
class="cxd-Form cxd-Form--horizontal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="a"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
A
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="a"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--horizontal"
data-amis-name="b"
data-role="form-item"
>
<label
class="cxd-Form-label cxd-Form-itemColumn--normal"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
B
</span>
</span>
</span>
</label>
<div
class="cxd-Form-value"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="b"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Modal-footer"
>
<button
class="cxd-Button cxd-Button--default cxd-Button--size-default"
type="button"
>
<span>
取消
</span>
</button>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="button"
>
<span>
确认
</span>
</button>
</div>
</div>
</div>
</body>
`;
exports[`Renderer:InputSubForm with addButtonClassName & itemsClassName & itemClassName & addButtonText & labelField 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="form2"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
多选
</span>
</span>
</span>
</label>
<div
class="cxd-SubFormControl cxd-Form-control"
>
<div
class="cxd-SubForm-values items-wrapper"
>
<div
class="cxd-SubForm-value item-classname"
>
<span
class="cxd-SubForm-valueLabel"
>
设置
</span>
<a
class="cxd-SubForm-valueEdit"
data-index="0"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
<a
class="cxd-SubForm-valueDel"
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-SubForm-value item-classname"
>
<span
class="cxd-SubForm-valueLabel"
>
设置
</span>
<a
class="cxd-SubForm-valueEdit"
data-index="1"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
<a
class="cxd-SubForm-valueDel"
data-index="1"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
</div>
<div
class="cxd-SubForm-toolbar"
>
<button
class="cxd-Button cxd-SubForm-addBtn thisis-add-btn"
type="button"
>
<icon-mock
classname="icon icon-plus"
icon="plus"
/>
<span>
自定义的新增
</span>
</button>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:InputSubForm with draggable & addable & removable 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="form"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
子Form
</span>
</span>
</span>
</label>
<div
class="cxd-SubFormControl cxd-Form-control"
>
<div
class="cxd-SubForm-values"
>
<div
class="cxd-SubForm-value"
>
<a
class="cxd-SubForm-valueDragBar"
>
<icon-mock
classname="icon icon-drag-bar"
icon="drag-bar"
/>
</a>
<span
class="cxd-SubForm-valueLabel"
>
<span
class="cxd-TplField fr-view"
>
<span>
设置val-b-change
</span>
</span>
</span>
<a
class="cxd-SubForm-valueEdit"
data-index="0"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
<a
class="cxd-SubForm-valueDel"
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-SubForm-value"
>
<a
class="cxd-SubForm-valueDragBar"
>
<icon-mock
classname="icon icon-drag-bar"
icon="drag-bar"
/>
</a>
<span
class="cxd-SubForm-valueLabel"
>
<span
class="cxd-TplField fr-view"
>
<span>
设置val-c
</span>
</span>
</span>
<a
class="cxd-SubForm-valueEdit"
data-index="1"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
<a
class="cxd-SubForm-valueDel"
data-index="1"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-SubForm-value"
>
<a
class="cxd-SubForm-valueDragBar"
>
<icon-mock
classname="icon icon-drag-bar"
icon="drag-bar"
/>
</a>
<span
class="cxd-SubForm-valueLabel"
>
<span
class="cxd-TplField fr-view"
>
<span>
设置val-d
</span>
</span>
</span>
<a
class="cxd-SubForm-valueEdit"
data-index="2"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
<a
class="cxd-SubForm-valueDel"
data-index="2"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
</div>
<div
class="cxd-SubForm-toolbar"
>
<span
class="cxd-Combo-dragableTip"
/>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:InputSubForm with multiple & maxLength & btnLabel 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="form"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
子Form
</span>
</span>
</span>
</label>
<div
class="cxd-SubFormControl cxd-Form-control"
>
<div
class="cxd-SubForm-values"
>
<div
class="cxd-SubForm-value"
>
<span
class="cxd-SubForm-valueLabel"
>
<span
class="cxd-TplField fr-view"
>
<span>
设置val-1-1
</span>
</span>
</span>
<a
class="cxd-SubForm-valueEdit"
data-index="0"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
<a
class="cxd-SubForm-valueDel"
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-SubForm-value"
>
<span
class="cxd-SubForm-valueLabel"
>
<span
class="cxd-TplField fr-view"
>
<span>
设置val-2-1
</span>
</span>
</span>
<a
class="cxd-SubForm-valueEdit"
data-index="1"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</a>
<a
class="cxd-SubForm-valueDel"
data-index="1"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
</div>
<div
class="cxd-SubForm-toolbar"
>
<button
class="cxd-Button cxd-SubForm-addBtn"
disabled=""
type="button"
>
<icon-mock
classname="icon icon-plus"
icon="plus"
/>
<span>
新增一项
</span>
</button>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
提交
</span>
</button>
</div>
</div>
</div>
</div>
`;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,680 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:InputTag InputTag input with batch tag 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="tag"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
标签
</span>
</span>
</span>
</label>
<div
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="downshift-3-menu"
class="cxd-Form-control cxd-TagControl"
role="combobox"
>
<div
class="cxd-ResultBox cxd-TagControl-input is-focused is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="0"
>
Apple
</span>
<a
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="1"
>
Orange
</span>
<a
data-index="1"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="2"
>
Banana
</span>
<a
data-index="2"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<input
aria-autocomplete="list"
aria-controls="downshift-3-menu"
autocomplete="off"
class="cxd-ResultBox-value-input"
id="downshift-3-input"
name="tag"
placeholder=""
theme="cxd"
type="text"
value=""
/>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
</div>
</div>
</form>
</div>
`;
exports[`Renderer:InputTag InputTag input with batch tag and separator "|" 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="tag"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
标签
</span>
</span>
</span>
</label>
<div
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="downshift-4-menu"
class="cxd-Form-control cxd-TagControl"
role="combobox"
>
<div
class="cxd-ResultBox cxd-TagControl-input is-focused is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="0"
>
Apple
</span>
<a
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="1"
>
Orange
</span>
<a
data-index="1"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="2"
>
Banana
</span>
<a
data-index="2"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<input
aria-autocomplete="list"
aria-controls="downshift-4-menu"
autocomplete="off"
class="cxd-ResultBox-value-input"
id="downshift-4-input"
name="tag"
placeholder=""
theme="cxd"
type="text"
value=""
/>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
</div>
</div>
</form>
</div>
`;
exports[`Renderer:InputTag InputTag input with max quantity 2 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="tag"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
标签
</span>
</span>
</span>
</label>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Form-control cxd-TagControl"
role="combobox"
>
<div
class="cxd-ResultBox cxd-TagControl-input is-focused is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="0"
>
Apple
</span>
<a
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="1"
>
Orange
</span>
<a
data-index="1"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<input
aria-autocomplete="list"
autocomplete="off"
class="cxd-ResultBox-value-input"
id="downshift-5-input"
name="tag"
placeholder=""
theme="cxd"
type="text"
value="Banana"
/>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
</div>
</div>
</form>
</div>
`;
exports[`Renderer:InputTag InputTag input with maxTagLength 5 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="tag"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
标签
</span>
</span>
</span>
</label>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Form-control cxd-TagControl"
role="combobox"
>
<div
class="cxd-ResultBox cxd-TagControl-input is-focused is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="0"
>
Apple
</span>
<a
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<input
aria-autocomplete="list"
autocomplete="off"
class="cxd-ResultBox-value-input"
id="downshift-6-input"
name="tag"
placeholder=""
theme="cxd"
type="text"
value="Banana"
/>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
</div>
</div>
</form>
</div>
`;
exports[`Renderer:InputTag InputTag input with single tag 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="tag"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
标签
</span>
</span>
</span>
</label>
<div
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="downshift-2-menu"
class="cxd-Form-control cxd-TagControl"
role="combobox"
>
<div
class="cxd-ResultBox cxd-TagControl-input is-focused is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<div
class="cxd-ResultBox-value"
>
<span
class="cxd-ResultBox-valueLabel"
data-index="0"
>
Honey-dew melon
</span>
<a
data-index="0"
>
<icon-mock
classname="icon icon-close"
icon="close"
/>
</a>
</div>
<input
aria-autocomplete="list"
aria-controls="downshift-2-menu"
autocomplete="off"
class="cxd-ResultBox-value-input"
id="downshift-2-input"
name="tag"
placeholder=""
theme="cxd"
type="text"
value=""
/>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
</div>
</div>
</form>
</div>
`;
exports[`Renderer:InputTag InputTag with options 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="tag"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
标签
</span>
</span>
</span>
</label>
<div
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="downshift-1-menu"
class="cxd-Form-control cxd-TagControl has-popover"
role="combobox"
>
<div
class="cxd-ResultBox cxd-TagControl-input is-focused is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<input
aria-autocomplete="list"
aria-controls="downshift-1-menu"
autocomplete="off"
class="cxd-ResultBox-value-input"
id="downshift-1-input"
name="tag"
placeholder="请输入/选择标签"
theme="cxd"
type="text"
value=""
/>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
<div
class="cxd-PopOver cxd-TagControl-popover"
role="popover"
style="display: block; left: 0px; top: 0px; visibility: hidden;"
theme="cxd"
>
<div
class="cxd-PopOver-overlay"
/>
<div
class="cxd-ListMenu"
>
<div
aria-selected="false"
class="cxd-ListMenu-item"
id="downshift-1-item-0"
role="option"
>
<div
class="cxd-ListMenu-itemLabel"
>
Apple
</div>
</div>
<div
aria-selected="false"
class="cxd-ListMenu-item"
id="downshift-1-item-1"
role="option"
>
<div
class="cxd-ListMenu-itemLabel"
>
Orange
</div>
</div>
<div
aria-selected="false"
class="cxd-ListMenu-item"
id="downshift-1-item-2"
role="option"
>
<div
class="cxd-ListMenu-itemLabel"
>
Banana
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
`;
exports[`Renderer:InputTag InputTag with placeholder 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="tag"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
标签
</span>
</span>
</span>
</label>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Form-control cxd-TagControl"
role="combobox"
>
<div
class="cxd-ResultBox cxd-TagControl-input is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<input
aria-autocomplete="list"
autocomplete="off"
class="cxd-ResultBox-value-input"
id="downshift-0-input"
name="tag"
placeholder="please input the tag"
theme="cxd"
type="text"
value=""
/>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
</div>
</div>
</form>
</div>
`;

View File

@@ -0,0 +1,394 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:inputYearRange with embed 1`] = `
<div>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
表单
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="year"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
年
</span>
</span>
</span>
</label>
<div
class="cxd-DateRangeControl cxd-Form-control"
>
<div
class="cxd-DateRangeCalendar"
>
<div
class="cxd-DateRangePicker-wrap"
>
<ul
class="cxd-DateRangePicker-rangers"
>
<li
class="cxd-DateRangePicker-ranger"
>
<a>
今年
</a>
</li>
<li
class="cxd-DateRangePicker-ranger"
>
<a>
去年
</a>
</li>
</ul>
<div
class="cxd-DateRangePicker-picker-wrap is-vertical"
>
<div
class="rdt rdtStatic rdtOpen cxd-DateRangePicker-start"
>
<div
class="rdtPicker rdtPickerDate"
>
<div
class="rdtYears"
>
<table
class="headerTable"
>
<thead>
<tr>
<th
class="rdtPrev"
>
«
</th>
<th
class="rdtSwitch"
>
1990 年 - 1999 年
</th>
<th
class="rdtNext"
>
»
</th>
</tr>
</thead>
</table>
<table>
<tbody>
<tr>
<td
class="rdtYear text-muted"
data-value="1989"
>
<span>
1989
</span>
</td>
<td
class="rdtYear"
data-value="1990"
>
<span>
1990
</span>
</td>
<td
class="rdtYear"
data-value="1991"
>
<span>
1991
</span>
</td>
</tr>
<tr>
<td
class="rdtYear"
data-value="1992"
>
<span>
1992
</span>
</td>
<td
class="rdtYear"
data-value="1993"
>
<span>
1993
</span>
</td>
<td
class="rdtYear"
data-value="1994"
>
<span>
1994
</span>
</td>
</tr>
<tr>
<td
class="rdtYear rdtBetween rdtActive rdtStart"
data-value="1995"
>
<span>
1995
</span>
</td>
<td
class="rdtYear rdtBetween"
data-value="1996"
>
<span>
1996
</span>
</td>
<td
class="rdtYear rdtBetween"
data-value="1997"
>
<span>
1997
</span>
</td>
</tr>
<tr>
<td
class="rdtYear rdtBetween"
data-value="1998"
>
<span>
1998
</span>
</td>
<td
class="rdtYear rdtBetween"
data-value="1999"
>
<span>
1999
</span>
</td>
<td
class="rdtYear text-muted rdtBetween"
data-value="2000"
>
<span>
2000
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class="rdt rdtStatic rdtOpen cxd-DateRangePicker-end"
>
<div
class="rdtPicker rdtPickerDate"
>
<div
class="rdtYears"
>
<table
class="headerTable"
>
<thead>
<tr>
<th
class="rdtPrev"
>
«
</th>
<th
class="rdtSwitch"
>
2070 年 - 2079 年
</th>
<th
class="rdtNext"
>
»
</th>
</tr>
</thead>
</table>
<table>
<tbody>
<tr>
<td
class="rdtYear text-muted rdtBetween"
data-value="2069"
>
<span>
2069
</span>
</td>
<td
class="rdtYear rdtBetween"
data-value="2070"
>
<span>
2070
</span>
</td>
<td
class="rdtYear rdtBetween"
data-value="2071"
>
<span>
2071
</span>
</td>
</tr>
<tr>
<td
class="rdtYear rdtBetween"
data-value="2072"
>
<span>
2072
</span>
</td>
<td
class="rdtYear rdtBetween"
data-value="2073"
>
<span>
2073
</span>
</td>
<td
class="rdtYear rdtBetween"
data-value="2074"
>
<span>
2074
</span>
</td>
</tr>
<tr>
<td
class="rdtYear rdtBetween"
data-value="2075"
>
<span>
2075
</span>
</td>
<td
class="rdtYear rdtBetween rdtActive rdtEnd"
data-value="2076"
>
<span>
2076
</span>
</td>
<td
class="rdtYear is-disabled"
data-value="2077"
>
<span>
2077
</span>
</td>
</tr>
<tr>
<td
class="rdtYear is-disabled"
data-value="2078"
>
<span>
2078
</span>
</td>
<td
class="rdtYear is-disabled"
data-value="2079"
>
<span>
2079
</span>
</td>
<td
class="rdtYear text-muted is-disabled"
data-value="2080"
>
<span>
2080
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="cxd-Panel-btnToolbar cxd-Panel-footer"
>
<button
class="cxd-Button cxd-Button--primary cxd-Button--size-default"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
`;

Some files were not shown because too many files have changed in this diff Show More