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,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>
`;

View File

@@ -0,0 +1,446 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:list 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-ListControl cxd-Form-control"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
Option A
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
Option B
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemImage"
>
<img
alt="OptionC"
src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg"
/>
</div>
<div
class="cxd-ListControl-itemLabel"
>
OptionC
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:list: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-ListControl cxd-Form-control"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
Option A
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
Option B
</div>
</div>
</div>
</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:list: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-ListControl cxd-Form-control"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
Option A
</div>
</div>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
Option B
</div>
</div>
</div>
</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:list: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-ListControl cxd-Form-control"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
Option A
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
Option B
</div>
</div>
</div>
</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>
`;

View File

@@ -0,0 +1,215 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:listSelect with image option & listClassName 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="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-ListControl cxd-Form-control"
>
<div
class="cxd-ListControl-items items-wrapper"
>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemImage"
>
<img
alt="OptionA"
src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg"
/>
</div>
<div
class="cxd-ListControl-itemLabel"
>
OptionA
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemImage"
>
<img
alt="OptionB"
src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg"
/>
</div>
<div
class="cxd-ListControl-itemLabel"
>
OptionB
</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>
提交
</span>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:listSelect with 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>
表单
</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-ListControl cxd-Form-control"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
Option A
</div>
</div>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
Option B
</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>
`;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,510 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`options:linkage 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"
>
<label
class="cxd-Form-label text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项x
</span>
</span>
</span>
</label>
<div
class="cxd-ListControl cxd-Form-control is-inline"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项1
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项2
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项3
</div>
</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 text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项y
</span>
</span>
</span>
</label>
<div
class="cxd-RadiosControl cxd-Form-control is-inline is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项a
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项b
</span>
</label>
</div>
</div>
</form>
</div>
`;
exports[`options:linkage 2`] = `
<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"
>
<label
class="cxd-Form-label text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项x
</span>
</span>
</span>
</label>
<div
class="cxd-ListControl cxd-Form-control is-inline"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
选项1
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项2
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项3
</div>
</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 text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项y
</span>
</span>
</span>
</label>
<div
class="cxd-RadiosControl cxd-Form-control is-inline is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default disabled cxd-Checkbox--radio--default--disabled--unchecked"
data-role="checkbox"
>
<input
disabled=""
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项a
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项b
</span>
</label>
</div>
</div>
</form>
</div>
`;
exports[`options:linkage 3`] = `
<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"
>
<label
class="cxd-Form-label text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项x
</span>
</span>
</span>
</label>
<div
class="cxd-ListControl cxd-Form-control is-inline"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项1
</div>
</div>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
选项2
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项3
</div>
</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 text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项y
</span>
</span>
</span>
</label>
<div
class="cxd-RadiosControl cxd-Form-control is-inline is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项a
</span>
</label>
</div>
</div>
</form>
</div>
`;
exports[`options:linkage 4`] = `
<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"
>
<label
class="cxd-Form-label text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项x
</span>
</span>
</span>
</label>
<div
class="cxd-ListControl cxd-Form-control is-inline"
>
<div
class="cxd-ListControl-items"
>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项1
</div>
</div>
<div
class="cxd-ListControl-item"
>
<div
class="cxd-ListControl-itemLabel"
>
选项2
</div>
</div>
<div
class="cxd-ListControl-item is-active"
>
<div
class="cxd-ListControl-itemLabel"
>
选项3
</div>
</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 text-muted"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选项y
</span>
</span>
</span>
</label>
<div
class="cxd-RadiosControl cxd-Form-control is-inline is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项a
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项b
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="text-muted"
>
选项c
</span>
</label>
</div>
</div>
</form>
</div>
`;

View File

@@ -0,0 +1,186 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:panel 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"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-Panel cxd-Panel--default"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
bla bla
</span>
</span>
</h3>
</div>
<div
class="bg-white"
>
<span
class="cxd-PlainField"
>
<span
class="text-muted"
>
Text
</span>
</span>
</div>
<div
class="cxd-Panel-footerWrap"
>
<div
class="bg-black"
>
<span
class="cxd-TplField fr-view"
>
<span>
<p>
footer 内容
</p>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
<div
class="cxd-Hbox-col"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-role="form-item"
>
<div
class="cxd-Panel cxd-Panel--default"
data-role="container"
>
<div
class="cxd-Panel-heading"
>
<h3
class="cxd-Panel-title"
>
<span
class="cxd-TplField fr-view"
>
<span>
bla bla
</span>
</span>
</h3>
</div>
<div
class="cxd-Panel-body"
>
<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 1"
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"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="text2"
placeholder="Text 2"
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,506 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:radios 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="radios"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
radios
</span>
</span>
</span>
</label>
<div
class="cxd-RadiosControl cxd-Form-control is-inline is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option A
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option B
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option C
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option D
</span>
</label>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="radios"
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>
`;
exports[`Renderer:radios 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="radios"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
radios
</span>
</span>
</span>
</label>
<div
class="cxd-RadiosControl cxd-Form-control is-inline is-thin"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default checked cxd-Checkbox--radio--default--checked"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option A
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option B
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option C
</span>
</label>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class=""
>
Option D
</span>
</label>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="radios"
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:radios source & autoFill 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="radios"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
radios
</span>
</span>
</span>
</label>
<div
class="cxd-RadiosControl cxd-Form-control is-thin"
>
<div
class="cxd-Grid"
>
<div
class="cxd-Grid-col--sm4"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
checked=""
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="class-a"
>
A
</span>
</label>
</div>
<div
class="cxd-Grid-col--sm4"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="class-a"
>
B
</span>
</label>
</div>
<div
class="cxd-Grid-col--sm4"
>
<label
class="cxd-Checkbox cxd-Checkbox--radio--default checked cxd-Checkbox--radio--default--checked"
data-role="checkbox"
>
<input
type="radio"
/>
<i>
<div
class="radio-icon icon"
/>
</i>
<span
class="class-a"
>
C
</span>
</label>
</div>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="radios"
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"
>
aa
</span>
</div>
</div>
</div>
<span
class="cxd-TplField fr-view autoFillClass"
>
<span>
13
</span>
</span>
</form>
</div>
</div>
</div>
`;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,988 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:rating with allowClear 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="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
评分
</span>
</span>
</span>
</label>
<div
class="cxd-RatingControl cxd-Form-control"
>
<div
class="cxd-Rating"
>
<ul>
<li
class="cxd-Rating-star"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
</ul>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="rating"
data-role="form-item"
>
<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="0"
autocomplete="off"
class="cxd-Number-input"
name="rating"
role="spinbutton"
step="1"
value="0"
/>
</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>
`;
exports[`Renderer:rating with char & charClassName 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="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
评分
</span>
</span>
</span>
</label>
<div
class="cxd-RatingControl cxd-Form-control"
>
<div
class="cxd-Rating"
>
<ul>
<li
class="cxd-Rating-star test-rating-char is-active"
>
X
</li>
<li
class="cxd-Rating-star test-rating-char is-active"
>
X
</li>
<li
class="cxd-Rating-star test-rating-char"
>
X
</li>
<li
class="cxd-Rating-star test-rating-char"
>
X
</li>
<li
class="cxd-Rating-star test-rating-char"
>
X
</li>
</ul>
</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:rating with colors & inactiveColor 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="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
评分
</span>
</span>
</span>
</label>
<div
class="cxd-RatingControl cxd-Form-control"
>
<div
class="cxd-Rating"
>
<ul>
<li
class="cxd-Rating-star is-active"
style="color: rgb(119, 168, 141);"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
style="color: rgb(119, 168, 141);"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
style="color: rgb(119, 168, 141);"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star"
style="color: yellow;"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star"
style="color: yellow;"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
</ul>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选中数量
</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="rating"
role="spinbutton"
step="1"
value="3"
/>
</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>
`;
exports[`Renderer:rating with count & half 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="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
评分
</span>
</span>
</span>
</label>
<div
class="cxd-RatingControl cxd-Form-control"
>
<div
class="cxd-Rating"
>
<ul>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-half"
>
<div
class="cxd-Rating-star-half"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</div>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
</ul>
</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:rating with readOnly 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="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
评分
</span>
</span>
</span>
</label>
<div
class="cxd-RatingControl cxd-Form-control"
>
<div
class="cxd-Rating"
>
<ul>
<li
class="cxd-Rating-star is-active is-disabled"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active is-disabled"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active is-disabled"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active is-disabled"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active is-disabled"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
</ul>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="rating"
data-role="form-item"
>
<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="rating"
role="spinbutton"
step="1"
value="5"
/>
</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>
`;
exports[`Renderer:rating with texts & textPosition & textClassName 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="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
评分
</span>
</span>
</span>
</label>
<div
class="cxd-RatingControl cxd-Form-control"
>
<div
class="cxd-Rating"
>
<span
class="cxd-Rating-text test-rating-class cxd-Rating-text--left"
>
非常优秀
</span>
<ul>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
<li
class="cxd-Rating-star is-active"
>
<icon-mock
classname="icon icon-star"
icon="star"
/>
</li>
</ul>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="rating"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
选中数量
</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="rating"
role="spinbutton"
step="1"
value="5"
/>
</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>
`;

View File

@@ -0,0 +1,271 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:repeat 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>
repeat
</span>
</span>
</span>
</label>
<div
class="cxd-RepeatControl cxd-Form-control"
>
<div
class="repeat-control hbox"
>
<div
class="col v-middle"
style="width: 30px;"
>
<span>
每
</span>
</div>
<div
class="col v-middle"
>
<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>
1
</span>
</div>
</div>
</div>
</div>
</div>
<div
class="col v-middle repeat-btn"
>
<div
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="downshift-0-menu"
class="cxd-Select is-opened pull-right has-popover"
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
class="cxd-PopOver cxd-Select-popover"
role="popover"
style="display: block; width: 0px; left: 0px; top: 0px; visibility: hidden;"
theme="cxd"
>
<div
class="cxd-PopOver-overlay"
/>
<div
class="cxd-Select-menu"
>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-0"
role="option"
>
<span
class="cxd-Select-option-content"
title="不重复"
>
不重复
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-1"
role="option"
>
<span
class="cxd-Select-option-content"
title="秒"
>
秒
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-2"
role="option"
>
<span
class="cxd-Select-option-content"
title="分"
>
分
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-3"
role="option"
>
<span
class="cxd-Select-option-content"
title="时"
>
时
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-4"
role="option"
>
<span
class="cxd-Select-option-content"
title="天"
>
天
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-5"
role="option"
>
<span
class="cxd-Select-option-content"
title="周中"
>
周中
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-6"
role="option"
>
<span
class="cxd-Select-option-content"
title="周"
>
周
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option"
id="downshift-0-item-7"
role="option"
>
<span
class="cxd-Select-option-content"
title="月"
>
月
</span>
</div>
<div
aria-selected="false"
class="cxd-Select-option is-active"
id="downshift-0-item-8"
role="option"
>
<span
class="cxd-Select-option-content"
title="年"
>
年
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,358 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:service 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-required"
data-amis-name="tpl"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
模板
</span>
</span>
<span
class="cxd-Form-star"
>
*
</span>
</span>
</label>
<div
class="cxd-SelectControl cxd-Form-control is-inline"
>
<div
aria-expanded="false"
aria-haspopup="listbox"
class="cxd-Select"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-value"
>
模板1
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
</div>
</div>
<div
class="cxd-Service m-t"
>
<div
class="cxd-Form-item cxd-Form-item--normal is-required"
data-amis-name="dy_1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
动态字段1
</span>
</span>
<span
class="cxd-Form-star"
>
*
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="dy_1"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="dy_2"
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="dy_2"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`form:service:remoteData 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Service"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="child-a"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="child-a"
placeholder=""
size="10"
type="text"
value="123"
/>
</div>
</div>
</div>
</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="submit"
>
<span>
Submit
</span>
</button>
</div>
</form>
</div>
`;
exports[`form:service:remoteSchmea+data 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Service"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="child-a"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="child-a"
placeholder=""
size="10"
type="text"
value="123"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="child-b"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="child-b"
placeholder=""
size="10"
type="text"
value="344"
/>
</div>
</div>
</div>
</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="submit"
>
<span>
Submit
</span>
</button>
</div>
</form>
</div>
`;
exports[`form:service:super-remoteData 1`] = `
<div>
<form
class="cxd-Form cxd-Form--normal"
novalidate=""
>
<input
style="display: none;"
type="submit"
/>
<div
class="cxd-Service"
>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="child-a"
data-role="form-item"
>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="child-a"
placeholder=""
size="10"
type="text"
value="123"
/>
</div>
</div>
</div>
</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="submit"
>
<span>
Submit
</span>
</button>
</div>
</form>
</div>
`;

View File

@@ -0,0 +1,505 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:static 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 bg-white"
data-amis-name="static"
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-static"
>
<div
class="cxd-Form-control is-inline"
>
<span
class="cxd-PlainField"
>
static
</span>
</div>
</div>
<span
class="cxd-TplField fr-view cxd-Form-description"
>
<span>
static description
</span>
</span>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="static 1"
data-role="form-item"
>
<div
class="cxd-Form-static"
>
<div
class="cxd-Form-control"
>
<span
class="cxd-PlainField"
>
<span
class="text-muted"
>
-
</span>
</span>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="static 2"
data-role="form-item"
>
<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>
`;
exports[`Renderer:static-quickEdit-icon 1`] = `
<div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="static"
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-static"
>
<div
class="cxd-Field--quickEditable cxd-Form-control"
tabindex="0"
>
<span
class="cxd-PlainField"
>
static
</span>
<button
class="cxd-Button cxd-Button--link cxd-Button--size-default cxd-Field-quickEditBtn"
tabindex="-1"
type="button"
>
<i
class="fa fa-search cxd-Button-icon fa fa-search"
/>
</button>
</div>
</div>
</div>
</div>
`;
exports[`Renderer:static2 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 cxd-Form--isStatic"
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-Form-static cxd-Form-control"
>
1
</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-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>
<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>
c
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static cxd-Form-control"
>
3
</div>
</div>
<div
class="cxd-Form-group cxd-Form-group--hor cxd-Form-group--normal"
>
<div
class="cxd-Form-groupColumn"
>
<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-Form-static cxd-Form-control"
>
1
</div>
</div>
</div>
<div
class="cxd-Form-groupColumn"
>
<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-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>
</div>
<div
class="cxd-Form-groupColumn"
>
<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>
c
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static cxd-Form-control"
>
3
</div>
</div>
</div>
</div>
<div
class="cxd-Form-group cxd-Form-group--hor cxd-Form-group--normal"
>
<div
class="cxd-Form-groupColumn"
>
<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-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>
<div
class="cxd-Form-groupColumn"
>
<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-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>
</div>
<div
class="cxd-Form-groupColumn"
>
<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>
c
</span>
</span>
</span>
</label>
<div
class="cxd-Form-static cxd-Form-control"
>
3
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,180 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:Switch Switch basic props 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 block"
data-amis-name="switch"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
开关
</span>
</span>
</span>
</label>
<div
class="cxd-SwitchControl cxd-Form-control is-thin"
>
<label
class="cxd-Switch is-checked"
data-role="switch"
>
<input
checked=""
theme="cxd"
type="checkbox"
/>
<span
class="text"
>
已开启飞行模式
</span>
<span
class="slider"
/>
</label>
<span
class="cxd-Switch-option"
>
switch
</span>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:Switch Switch size 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="switch"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
开关
</span>
</span>
</span>
</label>
<div
class="cxd-SwitchControl cxd-Form-control is-thin"
>
<label
class="cxd-Switch cxd-Switch--sm"
data-role="switch"
>
<input
theme="cxd"
type="checkbox"
/>
<span
class="text"
/>
<span
class="slider"
/>
</label>
<span
class="cxd-Switch-option"
/>
</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,180 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:tabs 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-Tabs cxd-Tabs--line"
data-role="container"
>
<div
class="cxd-Tabs-linksContainer-wrapper"
>
<div
class="cxd-Tabs-linksContainer"
>
<div
class="cxd-Tabs-linksContainer-main"
>
<ul
class="cxd-Tabs-links"
role="tablist"
>
<li
class="cxd-Tabs-link is-active"
>
<a
title="基本配置"
>
<span
class="cxd-Tabs-link-text"
>
基本配置
</span>
</a>
</li>
<li
class="cxd-Tabs-link"
>
<a
title="其他配置"
>
<span
class="cxd-Tabs-link-text"
>
其他配置
</span>
</a>
</li>
</ul>
</div>
</div>
</div>
<div
class="cxd-Tabs-content"
>
<div
class="in is-active cxd-Tabs-pane"
>
<span
class="cxd-TplField fr-view"
>
<span>
<p>
tab1 内容
</p>
</span>
</span>
</div>
<div
class="cxd-Tabs-pane"
>
<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>
文本3
</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=""
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="d"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
文本4
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="d"
placeholder=""
size="10"
type="text"
value=""
/>
</div>
</div>
</div>
</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,366 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:textarea 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>
textarea
</span>
</span>
</span>
</label>
<div
class="cxd-TextareaControl cxd-Form-control"
>
<textarea
autocomplete="off"
autocorrect="off"
class="cxd-TextareaControl-input"
name="a"
spellcheck="false"
>
456
</textarea>
</div>
</div>
</form>
</div>
</div>
</div>
`;
exports[`Renderer:textarea with maxLength & clearable & resetValue 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 has-error--maxLength"
data-amis-name="text"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
textarea
</span>
</span>
</span>
</label>
<div
class="cxd-TextareaControl is-focused cxd-Form-control is-error has-error--maxLength"
>
<textarea
autocomplete="off"
autocorrect="off"
class="cxd-TextareaControl-input cxd-TextareaControl-input--counter"
maxlength="9"
name="text"
spellcheck="false"
>
i am reset value
</textarea>
<a
class="cxd-TextareaControl-clear"
>
<icon-mock
classname="icon icon-input-clear"
icon="input-clear"
/>
</a>
<span
class="cxd-TextareaControl-counter is-clearable"
>
<span>
16
</span>
<i>
/
</i>
<span>
9
</span>
</span>
</div>
<ul
class="cxd-Form-feedback"
>
<li>
请控制内容长度, 不要输入 9 个以上字符
</li>
</ul>
</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:textarea with readOnly 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="text"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
textarea
</span>
</span>
</span>
</label>
<div
class="cxd-TextareaControl is-disabled cxd-Form-control"
>
<textarea
autocomplete="off"
autocorrect="off"
class="cxd-TextareaControl-input"
name="text"
readonly=""
spellcheck="false"
>
123
</textarea>
</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:textarea with trimContents & showCounter 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="text"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
textarea
</span>
</span>
</span>
</label>
<div
class="cxd-TextareaControl cxd-Form-control"
>
<textarea
autocomplete="off"
autocorrect="off"
class="cxd-TextareaControl-input cxd-TextareaControl-input--counter"
name="text"
spellcheck="false"
>
12345
</textarea>
<span
class="cxd-TextareaControl-counter"
>
<span>
5
</span>
</span>
</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,120 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:transfer-picker 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="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-TransferControl cxd-Form-control"
>
<div
class="cxd-ResultBox cxd-TransferPicker is-active is-clickable is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<span
class="cxd-ResultBox-placeholder"
>
请选择
</span>
<span
class="cxd-TransferPicker-icon"
>
<icon-mock
classname="icon icon-pencil"
icon="pencil"
/>
</span>
</div>
<div
class="cxd-ResultBox-actions"
/>
</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,83 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Renderer:usersselect 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="usersselect"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
人员选择
</span>
</span>
</span>
</label>
<div
class="UserSelectControl cxd-Form-control"
>
<div
class="cxd-UserSelect"
>
<div
class="cxd-ResultBox cxd-UserSelect-input is-clickable is-group"
tabindex="-1"
>
<div
class="cxd-ResultBox-value-wrap"
>
<span
class="cxd-ResultBox-placeholder"
>
请选择
</span>
</div>
<div
class="cxd-ResultBox-actions"
/>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,358 @@
// 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="test1"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
test1
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test1"
placeholder=""
size="10"
type="text"
value="1"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
test2(test)
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test"
placeholder=""
size="10"
type="text"
value="123"
/>
</div>
</div>
</div>
<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>
test3(test1)
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test1"
placeholder=""
size="10"
type="email"
value="1"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test4"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
test4
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test4"
placeholder=""
size="10"
type="text"
value="$"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test5"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
test5
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test5"
placeholder=""
size="10"
type="text"
value="\${test}"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="switch"
data-role="form-item"
>
<div
class="cxd-SwitchControl cxd-Form-control is-thin"
>
<label
class="cxd-Switch"
data-role="switch"
>
<input
checked=""
theme="cxd"
type="checkbox"
/>
<span
class="text"
/>
<span
class="slider"
/>
</label>
<span
class="cxd-Switch-option"
>
开关
</span>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test6"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
test6
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test6"
placeholder=""
size="10"
type="text"
value="test: 123, test1: 1"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test7"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
test7(test6)
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test7"
placeholder=""
size="10"
type="text"
value="test: 123, test1: 1"
/>
</div>
</div>
</div>
<div
class="cxd-Form-item cxd-Form-item--normal"
data-amis-name="test8"
data-role="form-item"
>
<label
class="cxd-Form-label"
>
<span>
<span
class="cxd-TplField fr-view"
>
<span>
test8
</span>
</span>
</span>
</label>
<div
class="cxd-Form-control cxd-TextControl"
>
<div
class="cxd-TextControl-input"
>
<input
autocomplete="off"
class=""
name="test8"
placeholder=""
size="10"
type="text"
value="test1: 1, switch: false"
/>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
`;

View File

@@ -0,0 +1,46 @@
import React = require('react');
import {render, cleanup} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:array', async () => {
const {container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
name: 'array',
label: '颜色集合',
type: 'array',
addable: true,
removeable: true,
minLength: 1,
maxLength: 4,
addButtonText: '新增',
draggable: true,
draggableTip: '可通过拖动每行中的【交换】按钮进行顺序调整',
value: ['red'],
inline: true,
items: {
type: 'color'
}
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,604 @@
/**
* 功能名称:autoFill 自动填充
* 单测内容:
* 01. 字段填充
* 02. 字段填充 & 提交表单
* 03. 字段填充的表单项name为对象路径格式
* 04. 字段填充(多选模式)
* 05. 字段填充后正常触发表单项校验 & validateOnChange正常触发
*/
import React from 'react';
import {
render,
cleanup,
screen,
fireEvent,
waitFor
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
const optisons = [
{label: 'OptionA', value: 'a'},
{label: 'OptionB', value: 'b'}
];
test('Form:options:autoFill', async () => {
const {container, getByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
body: [
{
type: 'radios',
name: 'a',
autoFill: {
aValue: '${value}',
aLabel: '${label}',
aId: '${id}'
},
options: [
{
label: 'OptionA',
value: 'a',
id: 233
},
{
label: 'OptionB',
value: 'b'
}
]
},
{
type: 'input-text',
name: 'a'
},
{
type: 'input-text',
name: 'aValue'
},
{
type: 'input-text',
name: 'aLabel'
},
{
type: 'input-text',
name: 'aId'
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
// expect(container).toMatchSnapshot();
fireEvent.click(getByText(/OptionA/));
await wait(500);
expect(container.querySelector('input[name=a]')?.getAttribute('value')).toBe(
'a'
);
expect(
container.querySelector('input[name=aValue]')?.getAttribute('value')
).toBe('a');
expect(
container.querySelector('input[name=aLabel]')?.getAttribute('value')
).toBe('OptionA');
expect(
container.querySelector('input[name=aId]')?.getAttribute('value')
).toBe('233');
fireEvent.click(getByText(/OptionB/));
await wait(1000);
expect(container.querySelector('input[name=a]')?.getAttribute('value')).toBe(
'b'
);
expect(
container.querySelector('input[name=aValue]')?.getAttribute('value')
).toBe('b');
expect(
container.querySelector('input[name=aLabel]')?.getAttribute('value')
).toBe('OptionB');
expect(
container.querySelector('input[name=aId]')?.getAttribute('value')
).toBe('');
});
test('Form:options:autoFill:data', async () => {
const onSubmit = jest.fn();
const {debug, container, getByText, findByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'radios',
name: 'a',
autoFill: {
aValue: '${value}',
aLabel: '${label}',
aId: '${id}'
},
options: [
{
label: 'OptionA',
value: 'a',
id: 233
},
{
label: 'OptionB',
value: 'b'
}
]
}
],
submitText: 'Submit'
},
{
onSubmit: onSubmit
},
makeEnv()
)
);
fireEvent.click(await findByText(/OptionA/));
await wait(500);
fireEvent.click(getByText(/Submit/));
await wait(200);
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
fireEvent.click(getByText(/OptionB/));
await wait(500);
fireEvent.click(getByText(/Submit/));
await wait(200);
expect(onSubmit).toBeCalledTimes(2);
expect(onSubmit.mock.calls[1][0]).toMatchSnapshot();
});
test('Form:options:autoFill:keyWithPath', async () => {
const {container} = render(
amisRender(
{
type: 'form',
body: [
{
type: 'radios',
label: 'trigger',
name: 'trigger',
autoFill: {
'receiver.target1': '${value}',
'receiver.target2': '${value}'
},
options: [
{label: 'OptionA', value: 'a'},
{label: 'OptionB', value: 'b'}
]
},
{
type: 'input-text',
name: 'receiver.target1',
label: 'receiver.target1'
},
{
type: 'input-text',
name: 'receiver.target2',
label: 'receiver.target2'
},
{
type: 'input-text',
name: 'standalone',
label: 'standalone',
value: 'abc'
}
]
},
{},
makeEnv()
)
);
const triggerA = await screen.findByText(/OptionA/);
const triggerB = await screen.findByText(/OptionB/);
const target1 = container.querySelector(
'input[name=receiver\\.target1]'
) as HTMLInputElement;
const target2 = container.querySelector(
'input[name=receiver\\.target2]'
) as HTMLInputElement;
const standalone = container.querySelector(
'input[name=standalone]'
) as HTMLInputElement;
fireEvent.click(triggerA);
await wait(1000);
expect(target1.getAttribute('value')).toEqual('a');
expect(target2.getAttribute('value')).toEqual('a');
expect(standalone.getAttribute('value')).toEqual('abc');
fireEvent.click(triggerB);
await wait(1000);
expect(target1.getAttribute('value')).toEqual('b');
expect(target2.getAttribute('value')).toEqual('b');
expect(standalone.getAttribute('value')).toEqual('abc');
});
test('Form:options:autoFill:multiple:data', async () => {
const onSubmit = jest.fn();
const {container, getByText, findByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'radios',
name: 'a',
multiple: true,
autoFill: {
aValues: '${items|pick:value}',
aLabels: '${items|pick:label}',
aIds: '${items|pick:id}'
},
options: [
{
label: 'OptionA',
value: 'a',
id: 233
},
{
label: 'OptionB',
value: 'b'
}
]
}
],
submitText: 'Submit'
},
{
onSubmit: onSubmit
},
makeEnv()
)
);
fireEvent.click(await findByText(/OptionA/));
await wait(500);
fireEvent.click(getByText(/Submit/));
await wait(200);
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
fireEvent.click(getByText(/OptionB/));
await wait(500);
fireEvent.click(getByText(/Submit/));
await wait(200);
expect(onSubmit).toBeCalledTimes(2);
expect(onSubmit.mock.calls[1][0]).toMatchSnapshot();
});
test('Form:options:autoFill:validation', async () => {
const onSubmitFn = jest.fn();
const submitText = 'Submit';
const validationMsg1 = '选项1校验失败,数据必须为Option B';
const validationMsg2 = '选项2校验失败,数据必须为Option B';
const {container} = render(
amisRender(
{
type: 'form',
submitText,
body: [
{
type: 'select',
label: '选项',
name: 'select',
placeholder: 'SelectCompt',
autoFill: {
instantValidate: '${label}',
submitValidate: '${label}'
},
clearable: true,
options: [
{label: 'OptionA', value: 'a'},
{label: 'OptionB', value: 'b'}
]
},
{
type: 'input-text',
name: 'instantValidate',
label: '选项1',
placeholder: '选项1',
description: '填充后立即校验',
required: true,
validateOnChange: true,
validations: {
equals: 'OptionB'
},
validationErrors: {
equals: validationMsg1
}
},
{
type: 'input-text',
name: 'submitValidate',
label: '选项2',
placeholder: '选项2',
description: '填充后提交表单时才校验',
required: true,
validations: {
equals: 'OptionB'
},
validationErrors: {
equals: validationMsg2
}
}
]
},
{onSubmit: onSubmitFn},
makeEnv({})
)
);
const select = container.querySelector(
'span[class*=Select-arrow]'
) as HTMLDivElement;
const option1 = container.querySelector(
'input[name=instantValidate]'
) as HTMLInputElement;
const option2 = container.querySelector(
'input[name=submitValidate]'
) as HTMLInputElement;
const submitBtn = screen.getByRole('button', {name: submitText});
// 自动填充触发后生成校验信息
fireEvent.click(select);
await wait(300);
fireEvent.click(screen.getByText(/OptionA/));
await wait(1000);
expect(option1.getAttribute('value')).toEqual('OptionA');
expect(option2.getAttribute('value')).toEqual('OptionA');
expect(screen.queryByText(validationMsg1)).toBeInTheDocument();
// 提交后校验选项2
fireEvent.click(submitBtn);
await wait(500);
expect(screen.queryByText(validationMsg2)).toBeInTheDocument();
// 自动填充再次触发后validateOnChange的选项消除校验信息
fireEvent.click(select);
await wait(300);
fireEvent.click(screen.getByText(/OptionB/));
await wait(1000);
expect(option1.getAttribute('value')).toEqual('OptionB');
expect(option1.getAttribute('value')).toEqual('OptionB');
expect(screen.queryByText(validationMsg1)).not.toBeInTheDocument();
expect(screen.queryByText(validationMsg2)).not.toBeInTheDocument();
// 提交后校验信息全部消除
fireEvent.click(submitBtn);
await wait(500);
expect(screen.queryByText(validationMsg1)).not.toBeInTheDocument();
expect(screen.queryByText(validationMsg2)).not.toBeInTheDocument();
});
test('6. AutoFill initAutoFill fillIfNotSet', async () => {
const onSubmit = jest.fn();
const {debug, container, getByText, findByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
title: 'The form',
controls: [
{
type: 'hidden',
name: 'aId',
value: 123
},
{
type: 'hidden',
name: 'bId'
},
{
type: 'radios',
name: 'a',
autoFill: {
aValue: '${value}',
aLabel: '${label}',
aId: '${id}',
bId: '${id}'
},
value: 'a',
options: [
{
label: 'OptionA',
value: 'a',
id: 233
},
{
label: 'OptionB',
value: 'b'
}
]
}
],
submitText: 'Submit'
}
]
},
{
onSubmit: onSubmit
},
makeEnv()
)
);
await wait(200);
fireEvent.click(getByText(/Submit/));
await wait(200);
expect(onSubmit).toBeCalledTimes(1);
expect(onSubmit.mock.calls[0][0]).toMatchObject({
aId: 123,
a: 'a',
aValue: 'a',
aLabel: 'OptionA',
bId: 233
});
});
test('7. AutoFill initAutoFill false', async () => {
const onSubmit = jest.fn();
const {debug, container, getByText, findByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
title: 'The form',
controls: [
{
type: 'hidden',
name: 'aId',
value: 123
},
{
type: 'hidden',
name: 'bId'
},
{
type: 'radios',
name: 'a',
autoFill: {
aValue: '${value}',
aLabel: '${label}',
aId: '${id}',
bId: '${id}'
},
initAutoFill: false,
value: 'a',
options: [
{
label: 'OptionA',
value: 'a',
id: 233
},
{
label: 'OptionB',
value: 'b'
}
]
}
],
submitText: 'Submit'
}
]
},
{
onSubmit: onSubmit
},
makeEnv()
)
);
await wait(200);
fireEvent.click(getByText(/Submit/));
await wait(200);
expect(onSubmit).toBeCalledTimes(1);
expect(onSubmit.mock.calls[0][0]).toMatchObject({
aId: 123,
a: 'a'
});
});
test('8. AutoFill initAutoFill true', async () => {
const onSubmit = jest.fn();
const {debug, container, getByText, findByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
title: 'The form',
controls: [
{
type: 'hidden',
name: 'aId',
value: 123
},
{
type: 'hidden',
name: 'bId'
},
{
type: 'radios',
name: 'a',
autoFill: {
aValue: '${value}',
aLabel: '${label}',
aId: '${id}',
bId: '${id}'
},
initAutoFill: true,
value: 'a',
options: [
{
label: 'OptionA',
value: 'a',
id: 233
},
{
label: 'OptionB',
value: 'b'
}
]
}
],
submitText: 'Submit'
}
]
},
{
onSubmit: onSubmit
},
makeEnv()
)
);
await wait(200);
fireEvent.click(getByText(/Submit/));
await wait(200);
expect(onSubmit).toBeCalledTimes(1);
expect(onSubmit.mock.calls[0][0]).toMatchObject({
aId: 233,
a: 'a',
aValue: 'a',
aLabel: 'OptionA',
bId: 233
});
});

View File

@@ -0,0 +1,65 @@
import React = require('react');
import {render, cleanup, fireEvent} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {wait, makeEnv} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:button', async () => {
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'button',
name: 'test',
label: 'Text',
icon: 'fa fa-plus'
},
{
type: 'button',
label: 'OpenDialog',
actionType: 'dialog',
dialog: {
confirmMode: false,
title: '提示',
body: '对,你刚点击了!'
}
},
{
type: 'submit',
level: 'primary',
label: 'Submit'
},
{
type: 'reset',
label: 'Reset',
level: 'danger',
size: 'sm',
className: 'r-2x'
}
],
submitText: null,
actions: []
},
{},
makeEnv({
getModalContainer: () => container
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/OpenDialog/));
await wait(300);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,243 @@
/**
* 组件名称:Button-Group-Select 按钮点选
* 单测内容:
1. 基本用法
2. clearable
3. vertical
4. tiled
5. btnActiveLevel
*/
import {render, cleanup, fireEvent, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
// 1. 基本用法
test('Renderer:button-group-select', async () => {
const {container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'button-group',
name: 'select',
label: '单选',
options: [
{
label: 'Option A',
value: 'a'
},
{
label: 'Option B',
value: 'b'
}
]
},
{
type: 'static',
name: 'select',
label: '当前值'
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
});
// 2. clearable
test('Renderer:button-group:multiple clearable', async () => {
const {getByText, container, findByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'button-group',
name: 'select',
label: '多选',
multiple: true,
clearable: true,
options: [
{
label: 'Option A',
value: 'a'
},
{
label: 'Option B',
value: 'b'
}
]
},
{
type: 'static',
name: 'select',
label: '当前值'
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
// 这个是为了用于监视值是否变更完成
const refDom = container.querySelector('.cxd-PlainField') as Element;
fireEvent.click(await findByText(/Option A/));
await waitFor(() => expect(refDom.innerHTML).toBe('a'));
expect(container).toMatchSnapshot();
fireEvent.click(await findByText(/Option B/));
await waitFor(() => expect(refDom.innerHTML).toBe('a,b'));
expect(container).toMatchSnapshot();
fireEvent.click(await findByText(/Option B/));
await waitFor(() => expect(refDom.innerHTML).toBe('a'));
expect(container).toMatchSnapshot();
});
// 3. vertical
test('Renderer:button-group with vertical', async () => {
const {getByText, container, findByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'button-group',
name: 'select',
label: '多选',
vertical: true,
options: [
{
label: 'Option A',
value: 'a'
},
{
label: 'Option B',
value: 'b'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(
container.querySelector('.cxd-ButtonGroup.cxd-ButtonGroup--vertical')!
).toBeInTheDocument();
expect(container).toMatchSnapshot();
});
// 4. tiled
test('Renderer:button-group with tiled', async () => {
const {getByText, container, findByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'button-group',
name: 'select',
label: '多选',
tiled: true,
options: [
{
label: 'Option A',
value: 'a'
},
{
label: 'Option B',
value: 'b'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(
container.querySelector('.cxd-ButtonGroup.cxd-ButtonGroup--tiled')!
).toBeInTheDocument();
expect(container).toMatchSnapshot();
});
// 5. btnActiveLevel
test('Renderer:button-group with btnActiveLevel', async () => {
const {getByText, container, findByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'button-group-select',
label: '选项',
name: 'type',
btnLevel: 'light',
btnActiveLevel: 'warning',
value: 'a',
options: [
{
label: 'Option A',
value: 'a',
level: 'primary'
},
{
label: 'Option B',
value: 'b',
level: 'primary'
},
{
label: 'Option C',
value: 'c'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
const buttons = container.querySelectorAll('.cxd-ButtonGroup .cxd-Button')!;
expect(buttons.length).toBe(3);
expect(container).toMatchSnapshot();
expect(buttons[0]).toHaveClass('cxd-Button--warning');
expect(buttons[1]).toHaveClass('cxd-Button--primary');
expect(buttons[2]).toHaveClass('cxd-Button--light');
});

View File

@@ -0,0 +1,65 @@
/**
* 组件名称:Button-Toolbar 按钮工具栏
* 单测内容:
* 1. 基础使用
*/
import {render, cleanup, fireEvent} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:button-toolbar', async () => {
let container: HTMLElement;
const renderResult: any = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'button-toolbar',
buttons: [
{
type: 'button',
label: 'OpenDialog',
actionType: 'dialog',
dialog: {
confirmMode: false,
title: '提示',
body: '对,你刚点击了!'
}
},
{
type: 'submit',
label: 'Submit'
},
{
type: 'reset',
label: 'Reset'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv({
getModalContainer: () => container
})
)
);
const getByText = renderResult.getByText;
container = renderResult.container;
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/OpenDialog/));
await wait(300);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,129 @@
/**
* 组件名称:Chained-Select 链式下拉框
* 单测内容:
* 1. 基础使用
*/
import {
render,
waitFor,
fireEvent,
waitForElementToBeRemoved
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, replaceReactAriaIds, wait} from '../../helper';
test('Renderer:chained-select', async () => {
const fetcher = jest.fn().mockImplementation((config: any) => {
return new Promise(resolve => {
const level = parseInt(config.query.level, 10) || 0;
const maxLevel = parseInt(config.query.maxLevel, 10) || 0;
if (level >= maxLevel) {
resolve({
status: 200,
headers: {},
data: {
status: 0,
data: null
}
});
} else {
resolve({
status: 200,
headers: {},
data: {
status: 0,
msg: '',
data: [
{
label: `A ${level}`,
value: 'a'
},
{
label: `B ${level}`,
value: 'b'
},
{
label: `C ${level}`,
value: 'c'
},
{
label: `D ${level}`,
value: 'd'
}
]
}
});
}
});
});
const {container, findByText, getByText, getByTestId} = render(
amisRender(
{
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
name: 'select3',
type: 'chained-select',
label: '级联下拉',
source: '/api/xxx?parentId=$parentId&level=$level&maxLevel=4',
value: 'a,b'
}
]
},
{},
makeEnv({
fetcher
})
)
);
await wait(500);
await waitFor(() => {
expect(fetcher).toBeCalledTimes(3);
expect(fetcher.mock.calls[2][0].query).toMatchObject({
parentId: 'b',
level: 2,
maxLevel: '4'
});
expect(getByText('B 1')).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
fireEvent.click(getByText('请选择'));
expect(getByText('D 2')).toBeInTheDocument();
fireEvent.click(getByText('D 2'));
await wait(100);
expect(fetcher).toBeCalledTimes(4);
expect(fetcher.mock.calls[3][0].query).toMatchObject({
parentId: 'd',
level: 3,
maxLevel: '4'
});
fireEvent.click(getByText('请选择'));
expect(getByText('C 3')).toBeInTheDocument();
fireEvent.click(getByText('C 3'));
await waitFor(() => {
expect(fetcher).toBeCalledTimes(5);
});
expect(container).not.toHaveTextContent('请选择');
expect(
container.querySelectorAll('.cxd-ChainedSelectControl > .cxd-Select')!
.length
).toBe(4);
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,125 @@
import React = require('react');
import {render, cleanup, fireEvent, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:checkbox', async () => {
const {container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
name: 'checkbox',
type: 'checkbox',
label: 'Checkbox',
option: '选项说明',
trueValue: true,
falseValue: false
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:checkbox with optionType', async () => {
const {container, getByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
name: 'checkbox',
type: 'checkbox',
label: 'Checkbox',
option: '去吃饭',
trueValue: '吃了',
falseValue: '没吃呢',
optionType: 'button',
value: '没吃呢'
},
{
type: 'static',
label: '您吃了吗',
name: 'checkbox'
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
await wait(300);
expect(
container.querySelector(
'.cxd-Checkbox.cxd-Checkbox--checkbox--button'
) as Element
).toBeInTheDocument();
fireEvent.click(getByText(/去吃饭/));
await waitFor(() => {
expect(
(container.querySelector('.cxd-PlainField') as Element).innerHTML
).toBe('吃了');
expect(
container.querySelector(
'.cxd-Checkbox.cxd-Checkbox--checkbox--button.cxd-Checkbox--checkbox--button--checked'
) as Element
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('Renderer:checkbox with checked', async () => {
const {container, getByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
name: 'checkbox',
type: 'checkbox',
label: 'Checkbox',
option: '选项说明',
checked: true
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
await wait(300);
expect(
container.querySelector('.cxd-Checkbox input[checked]') as Element
).toBeInTheDocument();
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,884 @@
/**
* 组件名称:Checkboxes 复选框
* 单测内容:
* 1. 基础点击勾选
* 2. 分组显示
* 3. 列数 columnsCount
* 4. 全选\全不选 checkAll
* 5. 自定义选项渲染 menuTpl
* 6. 分隔符 delimiter
* 7. 提取值 extractValue 与 拼接值 joinValues
* 8. 数据源 source、选项标签字段 labelField 与 选项值字段 valueField
* 9. 默认全部选中 defaultCheckAll 与 是否显示为一行 inline
* 10. 是否可新增 creatable、自定义新增按钮名称 createBtnLabel、自定义新增表单 addControls 与 新增选项接口 addApi
* 11. 是否可编辑 editable、自定义编辑表单 editControls 与 编辑接口 editApi
* 12. 是否可删除 removable、删除接口 deleteApi
* 13. 按钮模式 optionType、选项 label 自定义类名 labelClassName 与 选项自定义类名 itemClassName
*/
import React from 'react';
import {
render,
cleanup,
screen,
fireEvent,
waitFor
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
import {now} from 'lodash';
afterEach(() => {
cleanup();
clearStoresCache();
});
const setup = async (
items: any[] = [],
rest?: {
formOptions?: any;
props?: any;
env?: any;
}
) => {
const {props, formOptions, env} = rest || {};
const utils = render(
amisRender(
{
type: 'form',
api: '/api/mock2/form/saveForm',
body: items,
...(formOptions || {})
},
props || {},
makeEnv(env || {})
)
);
const submitBtn = utils.container.querySelector(
'button[type="submit"]'
) as HTMLElement;
return {
submitBtn,
...utils
};
};
const normalOptions = [
{
label: 'OptionA',
value: 'a',
klass: 'success'
},
{
label: 'OptionB',
value: 'b',
klass: 'danger'
},
{
label: 'OptionC',
value: 'c',
klass: 'warning'
},
{
label: 'OptionD',
value: 'd',
klass: 'info'
}
];
test('Renderer:checkboxes', async () => {
const {getByText, container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
name: 'checkboxes',
type: 'checkboxes',
label: 'Checkboxes',
columnsCount: 1,
options: normalOptions
},
{
type: 'static',
name: 'checkboxes',
label: '当前值'
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
await wait(500);
fireEvent.click(getByText(/OptionA/));
await wait(500);
fireEvent.click(getByText(/OptionB/));
await wait(500);
expect(container).toMatchSnapshot();
});
test('Renderer:checkboxes with group', async () => {
const {getByText, container} = await setup([
{
type: 'checkboxes',
name: 'checkboxes',
label: '城市选择',
inline: false,
options: [
{
label: 'A类型',
children: [
{
value: '选项 A-1',
label: 'a-1'
},
{
value: '选项 A-2',
label: 'a-2'
}
]
},
{
label: 'B类型',
children: [
{
value: '选项 B-1',
label: 'b-1'
},
{
value: '选项 B-2',
label: 'b-2'
},
{
value: '选项 B-3',
label: 'b-3'
},
{
value: '选项 B-4',
label: 'b-4'
}
]
},
{
value: '选项 C-1',
label: 'c-1'
}
]
}
]);
expect(container).toMatchSnapshot();
const groups = container.querySelectorAll('.cxd-CheckboxesControl-group');
expect(groups.length).toBe(2);
expect(
groups[0].querySelector('.cxd-CheckboxesControl-groupLabel')!.innerHTML
).toBe('A类型');
expect(groups[1].querySelectorAll('.cxd-Checkbox').length).toBe(4);
});
test('Renderer:checkboxes with columnsCount', async () => {
const {container} = await setup([
{
name: 'checkboxes2',
type: 'checkboxes',
label: '显示两列的复选框',
columnsCount: 2,
inline: false,
options: normalOptions
}
]);
expect(container).toMatchSnapshot();
expect(container.querySelector('.cxd-Grid')!.children.length).toBe(2);
const {container: containerTwo} = await setup([
{
name: 'checkboxes2',
type: 'checkboxes',
label: '数组形式显示的复选框',
columnsCount: [1, 2, 3],
inline: false,
options: normalOptions
}
]);
expect(containerTwo).toMatchSnapshot();
const grids = containerTwo.querySelectorAll('.cxd-Grid');
expect(grids.length).toBe(3);
expect(grids[0].children.length).toBe(1);
expect(grids[1].children.length).toBe(2);
const {container: containerWithGroup} = await setup([
{
type: 'checkboxes',
name: 'checkboxes',
label: '有分组的情况下显示分列的复选框',
inline: false,
columnsCount: 3,
options: [
{
label: 'A类型',
children: [
{
value: '选项 A-1',
label: 'a-1'
},
{
value: '选项 A-2',
label: 'a-2'
}
]
},
{
label: 'B类型',
children: [
{
value: '选项 B-1',
label: 'b-1'
},
{
value: '选项 B-2',
label: 'b-2'
},
{
value: '选项 B-3',
label: 'b-3'
},
{
value: '选项 B-4',
label: 'b-4'
}
]
}
]
}
]);
expect(containerWithGroup).toMatchSnapshot();
});
test('Renderer:checkboxes with checkall', async () => {
const {getByText, container} = await setup([
{
name: 'checkboxes',
type: 'checkboxes',
label: '复选框',
checkAll: true,
value: 'c,e',
options: [
{
label: 'GroupA',
children: normalOptions
},
{
label: 'GroupB',
children: [
{
label: 'OptionE',
value: 'e'
}
]
}
]
},
{
type: 'input-text',
name: 'checkboxes'
}
]);
const tpl = container.querySelector(
'.cxd-TextControl-input input'
)! as HTMLInputElement;
const checkAll = await screen.findByLabelText('全选/不选');
expect(tpl.value).toBe('c,e');
expect(checkAll).toBeVisible();
expect(container).toMatchSnapshot('default value');
fireEvent.click(checkAll);
await waitFor(() => {
expect(tpl.value).toBe('a,b,c,d,e');
expect(container).toMatchSnapshot('all selected');
});
fireEvent.click(checkAll);
await waitFor(() => {
expect(tpl.value).toBe('');
expect(container).toMatchSnapshot('no selected');
});
});
test('Renderer:checkboxes with menuTpl', async () => {
const {getByText, container} = await setup([
{
name: 'checkboxes',
type: 'checkboxes',
label: '复选框',
menuTpl: "<span class='label label-${klass}'>${label}</span>",
options: normalOptions
}
]);
const optionA = screen.getByText('OptionA');
expect(optionA).toBeVisible();
expect(optionA).toHaveClass('label label-success');
const optionC = screen.getByText('OptionA');
expect(optionC).toBeVisible();
expect(optionC).toHaveClass('label label-success');
expect(container).toMatchSnapshot();
});
test('Renderer:checkboxes with delimiter', async () => {
const {container, getByText} = await setup([
{
type: 'checkboxes',
name: 'checkboxes',
label: '选项分隔符组件',
delimiter: '#delimiter#',
options: normalOptions
},
{
type: 'static',
name: 'checkboxes'
}
]);
const tpl = container.querySelector('.cxd-PlainField')! as HTMLInputElement;
fireEvent.click(getByText(/OptionD/));
await waitFor(() => {
expect(tpl.innerHTML).toBe('d');
});
fireEvent.click(getByText(/OptionC/));
await waitFor(() => {
expect(tpl.innerHTML).toBe('d#delimiter#c');
});
});
test('Renderer:checkboxes with extractValue & joinValues', async () => {
const onSubmit = jest.fn();
const {container, getByText} = await setup(
[
{
type: 'checkboxes',
name: 'checkboxes',
label: '提取值',
joinValues: false,
extractValue: false,
options: normalOptions
},
{
type: 'checkboxes',
name: 'checkboxes-two',
label: '提取值',
joinValues: false,
extractValue: true,
options: [
{
label: 'OptionE',
value: 'e'
},
{
label: 'OptionF',
value: 'f'
},
{
label: 'OptionG',
value: 'g'
},
{
label: 'OptionH',
value: 'h'
}
]
}
],
{
props: {onSubmit},
formOptions: {
submitText: 'Submit'
}
}
);
fireEvent.click(getByText('OptionA'));
await wait(300);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toHaveBeenCalled();
});
expect(onSubmit.mock.calls[0][0].checkboxes).toMatchObject([
{
label: 'OptionA',
value: 'a',
klass: 'success'
}
]);
fireEvent.click(getByText('OptionB'));
await wait(300);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalledTimes(2);
});
expect(onSubmit.mock.calls[1][0].checkboxes).toMatchObject([
{
label: 'OptionA',
value: 'a',
klass: 'success'
},
{
label: 'OptionB',
value: 'b',
klass: 'danger'
}
]);
fireEvent.click(getByText('OptionE'));
await wait(300);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalledTimes(3);
});
expect(onSubmit.mock.calls[2][0]['checkboxes-two']).toMatchObject(['e']);
fireEvent.click(getByText('OptionH'));
await wait(300);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalledTimes(4);
});
expect(onSubmit.mock.calls[3][0]['checkboxes-two']).toMatchObject(['e', 'h']);
});
test('Renderer:checkboxes with source & labelField & valueField', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
options: [
{
iamlabel: 'Label A',
iamvalue: 'val-a'
},
{
iamlabel: 'Label B',
iamvalue: 'val-b'
}
],
value: 'val-a'
}
}
})
);
const onSubmit = jest.fn();
const {container, getByText} = await setup(
[
{
type: 'checkboxes',
name: 'checkboxes',
label: '复选框',
source: '/api/xxx',
labelField: 'iamlabel',
valueField: 'iamvalue'
}
],
{
props: {
onSubmit
},
formOptions: {
submitText: 'Submit'
},
env: {
fetcher
}
}
);
await waitFor(async () => {
expect(fetcher).toHaveBeenCalled();
expect(getByText('Label B')).toBeInTheDocument();
expect(container.querySelectorAll('.cxd-Checkbox').length).toBe(2);
await wait(200);
});
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0].checkboxes).toEqual('val-a');
});
});
test('Renderer:checkboxes with defaultCheckAll & inline', async () => {
const onSubmit = jest.fn();
const {container, getByText} = await setup(
[
{
type: 'checkboxes',
name: 'checkboxes',
label: '复选框',
value: 'a',
options: normalOptions
},
{
type: 'checkboxes',
name: 'checkboxes-two',
label: '复选框',
inline: false,
defaultCheckAll: true,
options: normalOptions
}
],
{
props: {onSubmit},
formOptions: {
submitText: 'Submit'
}
}
);
const Ins = container.querySelectorAll('.cxd-CheckboxesControl');
expect(Ins[0]!).toHaveClass('is-inline');
expect(Ins[1]!).not.toHaveClass('is-inline');
await wait(200);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchObject({
'checkboxes': 'a',
'checkboxes-two': 'a,b,c,d'
});
});
expect(container).toMatchSnapshot();
});
test('Renderer:checkboxes with creatable & createBtnLabel & addControls & addApi', async () => {
const onSubmit = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: ''
}
})
);
const {container, getByText, baseElement} = await setup(
[
{
type: 'checkboxes',
name: 'checkboxes',
label: '复选框',
creatable: true,
createBtnLabel: '我是新增按钮',
addControls: [
{
type: 'input-text',
name: 'label',
label: '名'
},
{
type: 'input-number',
name: 'value',
label: '值'
}
],
addApi: '/api/xxx',
options: normalOptions
}
],
{
props: {
onSubmit
},
formOptions: {
submitText: 'Submit'
},
env: {fetcher}
}
);
expect(getByText('我是新增按钮')).toBeInTheDocument();
// 点击新增按钮,打卡弹框
fireEvent.click(getByText('我是新增按钮'));
await waitFor(() => {
expect(baseElement.querySelector('.cxd-Modal-body')).toBeVisible();
expect(baseElement).toMatchSnapshot('dialog open');
});
// 新增表单输入
fireEvent.change(baseElement.querySelector('.cxd-TextControl-input input')!, {
target: {value: '我是label啊'}
});
fireEvent.change(baseElement.querySelector('.cxd-NumberControl input')!, {
target: {value: 555}
});
await wait(300);
// 表单提交
fireEvent.click(
baseElement.querySelector('.cxd-Modal-footer .cxd-Button--primary')!
);
await waitFor(async () => {
expect(fetcher).toHaveBeenCalled();
expect(fetcher.mock.calls[0][0].data.label).toEqual('我是label啊');
expect(fetcher.mock.calls[0][0].data.value).toEqual(555);
await wait(200);
});
const lastOption = container.querySelector(
'.cxd-CheckboxesControl .cxd-Checkbox:last-of-type'
)!;
expect(lastOption).toHaveTextContent('我是label啊');
expect(container).toMatchSnapshot('create success');
// 验证 value
fireEvent.click(lastOption.querySelector('input')!);
await wait(200);
fireEvent.click(getByText(/OptionA/));
await wait(200);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0].checkboxes).toEqual('555,a');
});
});
test('Renderer:checkboxes with editable & editControls & editApi', async () => {
const onSubmit = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: ''
}
})
);
const {container, getByText, baseElement} = await setup(
[
{
type: 'checkboxes',
name: 'checkboxes',
label: '复选框',
editable: true,
editControls: [
{
type: 'input-text',
name: 'label',
label: '名'
},
{
type: 'input-text',
name: 'value',
label: '值'
}
],
editApi: '/api/xxx',
options: normalOptions
}
],
{
props: {
onSubmit
},
formOptions: {
submitText: 'Submit'
},
env: {fetcher}
}
);
const optionD = container.querySelector(
'.cxd-CheckboxesControl .cxd-Checkbox:last-of-type'
)!;
fireEvent.mouseOver(optionD.querySelector('input')!);
await waitFor(() => {
expect(container).toMatchSnapshot('hover edit');
});
await wait(200);
const optionDEdit = container.querySelector(
'.cxd-CheckboxesControl .cxd-Checkbox:last-of-type a'
)!;
expect(optionDEdit).toBeVisible();
// 点击编辑按钮
fireEvent.click(optionDEdit.querySelector('icon-mock')!);
await waitFor(() => {
expect(baseElement.querySelector('.cxd-Modal-body')).toBeVisible();
expect(baseElement).toMatchSnapshot('dialog open');
});
const inputs = baseElement.querySelectorAll(
'.cxd-TextControl-input input'
) as unknown as HTMLInputElement[];
expect(inputs.length).toBe(2);
expect(inputs[0].value).toBe('OptionD');
expect(inputs[1].value).toBe('d');
// 新增表单输入
fireEvent.change(inputs[0], {
target: {value: 'OptionD 修改'}
});
fireEvent.change(inputs[1], {
target: {value: 'd-edit'}
});
await wait(300);
// 表单提交
fireEvent.click(
baseElement.querySelector('.cxd-Modal-footer .cxd-Button--primary')!
);
await waitFor(async () => {
expect(fetcher).toHaveBeenCalled();
expect(fetcher.mock.calls[0][0].data.label).toEqual('OptionD 修改');
expect(fetcher.mock.calls[0][0].data.value).toEqual('d-edit');
await wait(200);
});
const lastOption = container.querySelector(
'.cxd-CheckboxesControl .cxd-Checkbox:last-of-type'
)!;
expect(lastOption).toHaveTextContent('OptionD 修改');
expect(container).toMatchSnapshot('edit success');
// 验证 value
fireEvent.click(lastOption.querySelector('input')!);
await wait(200);
fireEvent.click(getByText(/OptionA/));
await wait(200);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0].checkboxes).toEqual('d-edit,a');
});
});
test('Renderer:checkboxes with removable & deleteApi', async () => {
const onSubmit = jest.fn();
const fetcher = jest.fn().mockImplementation((...args) => {
return Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: ''
}
});
});
const {container, getByText, baseElement} = await setup(
[
{
type: 'checkboxes',
name: 'checkboxes',
label: '复选框',
removable: true,
deleteApi: '/api/xxx',
options: normalOptions
}
],
{
props: {
onSubmit
},
formOptions: {
submitText: 'Submit'
},
env: {fetcher}
}
);
const optionA = container.querySelector(
'.cxd-CheckboxesControl .cxd-Checkbox:first-of-type'
)!;
fireEvent.mouseOver(optionA.querySelector('input')!);
await waitFor(() => {
expect(container).toMatchSnapshot('hover edit');
});
await wait(200);
const optionAEdit = optionA.querySelector('a')!;
expect(optionAEdit).toBeVisible();
// 点击删除按钮
fireEvent.click(optionAEdit.querySelector('icon-mock')!);
await waitFor(() => {
expect(baseElement.querySelector('.cxd-Modal-body')).toBeVisible();
expect(baseElement).toMatchSnapshot('dialog open');
});
// 确定
fireEvent.click(
baseElement.querySelector('.cxd-Modal-footer .cxd-Button--danger')!
);
await waitFor(async () => {
expect(fetcher).toHaveBeenCalled();
});
// 第一项变成了 OptionB
expect(
container.querySelector(
'.cxd-CheckboxesControl .cxd-Checkbox:first-of-type'
)!
).toHaveTextContent('OptionB');
});
test('Renderer:checkboxes with optionType & labelClassName & itemClassName', async () => {
const {getByText, container} = await setup([
{
name: 'checkboxes',
type: 'checkboxes',
label: '复选框',
optionType: 'button',
labelClassName: 'iamlabel',
itemClassName: 'iamitem',
value: 'c,e',
options: normalOptions
}
]);
const OptionA = container.querySelector(
'.cxd-CheckboxesControl .cxd-Checkbox:first-of-type'
)!;
expect(OptionA).toHaveClass('cxd-Checkbox--checkbox--button');
expect(OptionA).toHaveClass('iamitem');
expect(getByText(/OptionA/)).toHaveClass('iamlabel');
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,73 @@
import React = require('react');
import {render, fireEvent} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('Renderer:color', async () => {
// TODO: 改成 lazy 暂时不知如何处理
// const {container} = render(
// amisRender(
// {
// type: 'form',
// api: '/api/xxx',
// controls: [
// {
// type: 'color',
// name: 'a',
// label: 'color',
// value: '#51458f'
// }
// ],
// title: 'The form',
// actions: []
// },
// {},
// makeEnv({})
// )
// );
// const input = container.querySelector('input');
// expect(input?.value).toEqual('#51458f');
// fireEvent.change(input!, {
// target: {
// value: '#1a1438'
// }
// });
// expect(input?.value).toEqual('#1a1438');
// expect(container).toMatchSnapshot();
});
test('Renderer: no color value', async () => {
const {container} = render(
amisRender({
type: 'color',
})
);
const colorValue = container.querySelector('.cxd-ColorField-value');
expect(colorValue).not.toBeInTheDocument();
});
test('Renderer: defalut color value', async () => {
const {container} = render(
amisRender({
type: 'color',
defaultColor: '#ccc'
})
);
const colorValue = container.querySelector('.cxd-ColorField-value');
expect(colorValue).toBeInTheDocument();
});
test('Renderer: color value', async () => {
const {container} = render(
amisRender({
type: 'color',
value: '#ccc'
})
);
const colorValue = container.querySelector('.cxd-ColorField-value');
expect(colorValue).toBeInTheDocument();
});

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,53 @@
import React = require('react');
import {render, fireEvent} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
test('Renderer:container', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'container',
name: 'a',
label: 'container',
mode: 'horizontal',
className: 'no-border',
bodyClassName: 'bg-white',
horizontal: {
leftFixed: 1,
left: 4,
right: 7
},
controls: [
{
name: 'text',
type: 'text',
validation: 'isUrl',
addOn: {
label: '按钮',
type: 'submit'
}
},
{
name: 'text1',
type: 'text',
hidden: true
}
]
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,203 @@
import React = require('react');
import {render, cleanup, fireEvent, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Control:onChange', async () => {
const onChange = jest
.fn()
.mockImplementation((value: any, oldValue: any, model: any, form: any) => {
form.setValueByName('b', 2);
});
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
onSubmit,
wrapWithPanel: false,
controls: [
{
type: 'text',
name: 'a',
onChange: onChange
},
{
type: 'text',
name: 'b'
},
{
type: 'submit',
label: 'Submit'
}
]
},
{},
makeEnv()
)
);
// expect(container).toMatchSnapshot();
const input = container.querySelector('input[name=a]');
expect(input).toBeTruthy();
fireEvent.change(input!, {
target: {
value: '123'
}
});
await wait(300);
expect(onChange).toBeCalledTimes(1);
fireEvent.click(getByText('Submit'));
await wait(500);
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchObject({
a: '123',
b: 2
});
});
test('Control:formItem:reload', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
options: [
{
label: 'A',
value: 'a'
},
{
label: 'B',
value: 'b'
}
]
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
name: 'xForm',
wrapWithPanel: false,
controls: [
{
type: 'select',
name: 'a',
source: '/api/source'
}
],
submitText: null,
actions: []
},
{
type: 'button',
label: 'Reload',
actionType: 'reload',
target: 'xForm.a'
}
]
},
{},
makeEnv({
fetcher
})
)
);
await waitFor(() => {
expect(fetcher).toHaveBeenCalled();
});
fireEvent.click(getByText('Reload'));
await waitFor(() => {
expect(fetcher).toBeCalledTimes(2);
});
});
test('options:clearValueOnHidden ', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
wrapWithPanel: false,
onSubmit,
controls: [
{
label: '选项x',
type: 'list',
name: 'a',
autoFill: {
b: '${label}'
},
options: [
{
label: '选项1',
value: 1
},
{
label: '选项2',
value: 2
}
]
},
{
type: 'text',
name: 'b',
clearValueOnHidden: true,
visibleOn: 'data.a !== 2'
},
{
type: 'submit',
label: 'Submit'
}
]
},
{},
makeEnv({})
)
);
fireEvent.click(getByText('选项1'));
await wait(500);
fireEvent.click(getByText('Submit'));
await wait(500);
expect(onSubmit).toBeCalledTimes(1);
expect(onSubmit.mock.calls[0][0]).toMatchObject({
a: 1,
b: '选项1'
});
fireEvent.click(getByText('选项2'));
await wait(500);
fireEvent.click(getByText('Submit'));
await wait(500);
expect(onSubmit).toBeCalledTimes(2);
expect(onSubmit.mock.calls[1][0]).toMatchObject({
a: 2
});
});

View File

@@ -0,0 +1,329 @@
/**
* 组件名称:InputDateRange 日期范围
* 单测内容:
1. 默认值
2. 相对默认值
3. 快捷键
4. minDate & maxDate
5. 内嵌模式
6. minDuration & maxDuration
7. clearable
*/
import {render, fireEvent} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
const setup = async (items: any[] = []) => {
const onSubmit = jest.fn();
const utils = await render(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
await wait(200);
const submitBtn = utils.container.querySelector(
'button[type="submit"]'
) as HTMLElement;
const inputs = utils.container.querySelectorAll('.cxd-DateRangePicker-input');
function rerender(items: any[]) {
const onSubmit = jest.fn();
utils.rerender(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
}
return {
onSubmit,
submitBtn,
start: inputs[0],
end: inputs[1],
...utils,
rerender
};
};
// 1. 默认值
test('Renderer:dateRange with default', async () => {
const {container, start, end}: any = await setup([
{
type: 'input-date-range',
name: 'a',
label: 'date-range',
value: '1559750400,1561564799',
minDate: '1559664000',
maxDate: '1561737600'
}
]);
expect(start.value).toEqual(
`${moment(1559750400, 'X').format('YYYY-MM-DD')}`
);
expect(end.value).toEqual(`${moment(1561564799, 'X').format('YYYY-MM-DD')}`);
// expect(container).toMatchSnapshot();
});
// 2. 相对默认值
test('Renderer:dateRange with relative default', async () => {
const {container, start, end}: any = await setup([
{
type: 'input-date-range',
name: 'a',
label: 'date-range',
value: '-1day,+1weeks'
}
]);
expect(start.value).toEqual(moment().add(-1, 'day').format('YYYY-MM-DD'));
expect(end.value).toEqual(moment().add(+1, 'week').format('YYYY-MM-DD'));
// expect(container).toMatchSnapshot();
});
// 3. 快捷键
test('Renderer:dateRange with shortcuts', async () => {
const {container, start, end, getByText}: any = await setup([
{
type: 'input-date-range',
name: 'a',
label: 'date-range',
shortcuts: [
'7daysago',
'15dayslater',
'2weeksago',
'1weekslater',
'thismonth',
'2monthsago',
'3monthslater'
]
}
]);
fireEvent.click(container.querySelector('.cxd-DateRangePicker-input'));
await wait(200);
// expect(container).toMatchSnapshot('open');
expect(
container.querySelector('.cxd-DateRangePicker-rangers')!
).toBeInTheDocument();
expect(
container.querySelectorAll(
'.cxd-DateRangePicker-rangers > .cxd-DateRangePicker-ranger'
)!.length
).toBe(7);
expect(getByText('15天以内')).toBeInTheDocument();
fireEvent.click(getByText('15天以内'));
await wait(200);
expect(start.value).toEqual(moment().format('YYYY-MM-DD'));
expect(end.value).toEqual(moment().add(+15, 'day').format('YYYY-MM-DD'));
// expect(container).toMatchSnapshot();
});
// 4. minDate & maxDate
test('Renderer:dateRange with minDate and maxDate', async () => {
const {container} = await setup([
{
type: 'input-date-range',
name: 'date',
label: '日期',
valueFormat: 'YY-MM-DD',
minDate: '-1days',
maxDate: '+1days',
value: '-2days,+2days'
}
]);
fireEvent.click(container.querySelector('.cxd-DateRangePicker-input')!);
await wait(200);
expect(
container.querySelector(
'.cxd-DateRangePicker-picker-wrap .rdtDay.rdtActive.rdtDisabled'
)!
).toBeInTheDocument();
expect(
container.querySelector(
'.cxd-DateRangePicker-picker-wrap .rdtDay.rdtActive.rdtDisabled'
)!
).toBeInTheDocument();
});
// 5. 内嵌模式
test('Renderer:dateRange with embed', async () => {
const {container} = await setup([
{
type: 'input-date-range',
name: 'date',
label: '日期',
valueFormat: 'YY-MM-DD',
value: '1656604800,1664553599',
embed: true
}
]);
expect(
container.querySelector('.cxd-DateRangeCalendar')!
).toBeInTheDocument();
// expect(container).toMatchSnapshot();
});
// 6. minDuration & maxDuration
test('Renderer:dateRange with minDuration & maxDuration', async () => {
const {container, rerender} = await setup([
{
type: 'input-date-range',
name: 'select',
label: '日期范围',
value: 'today,+1days',
minDuration: '2days',
embed: true
}
]);
expect(
container.querySelector(
'.cxd-DateRangePicker-picker-wrap .rdtDay.rdtActive.rdtEnd.rdtDisabled'
)!
).toBeInTheDocument();
rerender([
{
type: 'input-date-range',
name: 'select',
label: '日期范围',
value: 'today,+3days',
maxDuration: '2days',
embed: true
}
]);
expect(
container.querySelector(
'.cxd-DateRangePicker-picker-wrap .rdtDay.rdtActive.rdtEnd.rdtDisabled'
)!
).toBeInTheDocument();
});
// 7. clearable
test('Renderer:dateRange with clearable', async () => {
const {container, rerender} = await setup([
{
type: 'input-date-range',
name: 'select',
label: '日期范围',
value: 'today,+1days'
}
]);
fireEvent.mouseEnter(container.querySelector('.cxd-DateRangePicker')!);
await wait(200);
expect(
container.querySelector('.cxd-DateRangePicker-clear')!
).toBeInTheDocument();
fireEvent.mouseLeave(container.querySelector('.cxd-DateRangePicker')!);
await wait(200);
rerender([
{
type: 'input-date-range',
name: 'select',
label: '日期范围',
clearable: false
}
]);
fireEvent.mouseEnter(container.querySelector('.cxd-DateRangePicker')!);
await wait(200);
expect(
container.querySelector('.cxd-DateRangePicker-clear')!
).not.toBeInTheDocument();
});
// 7. valueFormat/displayFormat
test('Renderer:inputDateRange compatible with format & inputFormat', async () => {
const {container, start, end}: any = await setup([
{
type: 'input-date-range',
name: 'a',
label: 'date-range',
value: '1559750400,1561564799',
displayFormat: 'DD/MM-YYYY',
valueFormat: 'X'
}
]);
expect(start.value).toEqual(
`${moment(1559750400, 'X').format('DD/MM-YYYY')}`
);
expect(end.value).toEqual(`${moment(1561564799, 'X').format('DD/MM-YYYY')}`);
});
// 8. 兼容format & inputFormat
test('Renderer:inputDateRange compatible with format & inputFormat', async () => {
const {container} = await setup([
{
type: 'input-date-range',
name: 'date1',
label: '日期',
value: '1559750400,1561564799',
inputFormat: 'DD/MM-YYYY',
format: 'X'
},
{
type: 'input-date-range',
name: 'date2',
label: '日期',
value: '1559750400,1561564799',
displayFormat: 'DD/MM-YYYY',
valueFormat: 'X'
}
]);
const inputs = container.querySelectorAll(
'.cxd-DateRangePicker-input'
)! as NodeListOf<HTMLInputElement>;
const first = {start: inputs[0].value, end: inputs[1].value};
const second = {start: inputs[2].value, end: inputs[3].value};
expect(first['start']).toEqual(second['start']);
expect(first['end']).toEqual(second['end']);
});

View File

@@ -0,0 +1,250 @@
import React = require('react');
import PageRenderer from '../../../../amis-core/src/renderers/Form';
import * as renderer from 'react-test-renderer';
import {
render,
screen,
fireEvent,
cleanup,
getByText
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
test('Renderer:datetime', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'datetime',
name: 'a',
label: 'date',
value: '1559826660',
minDate: '1559664000',
maxDate: '1561737600'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const input = container.querySelector(
'.cxd-DatePicker input'
)! as HTMLInputElement;
expect(input.value).toEqual(
moment(1559826660, 'X').format('YYYY-MM-DD HH:mm:ss')
);
expect(container).toMatchSnapshot();
});
test('Renderer:datetime displayFormat valueFormat', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'datetime',
name: 'b',
label: 'datetime',
value: '1559826660',
displayFormat: 'YYYY/MM/DD HH:mm:ss',
minDate: '1559664000',
maxDate: '1561737600'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const input = container.querySelector(
'.cxd-DatePicker input'
)! as HTMLInputElement;
expect(input.value).toEqual(
moment(1559826660, 'X').format('YYYY/MM/DD HH:mm:ss')
);
});
/**
* CASE: 日期时间选择器确认模式
* 前提条件:
* - 当前组件为input-datetime类型
* - closeOnSelect为false
* - 未开启内嵌模式
* - 非移动端交互
* 预期:
* 1. 选择日期后,点击取消按钮,值重置
* 2. 选择日期后,点击确定按钮,值更新
*/
test('Renderer:InputDateTime confirm mode', async () => {
const {container} = render(
amisRender(
{
type: 'form',
body: [
{
name: 'datetime',
label: '日期',
type: 'input-datetime',
closeOnSelect: false
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const trigger = container.querySelector('.cxd-DatePicker')!;
const inputEl = (container.querySelector(
'.cxd-DatePicker-input'
) as HTMLInputElement)!;
const getCancelBtn = () =>
container.querySelector(
'.cxd-DateRangePicker-actions > button[type=button]'
)!;
const getConfirmBtn = () =>
container.querySelector(
'.cxd-DateRangePicker-actions > .cxd-Button.cxd-Button--primary'
)!;
expect(trigger).toBeInTheDocument();
fireEvent.click(trigger);
wait(200);
/** 未选择新值,确认按钮禁用 */
expect(getConfirmBtn()).toHaveClass('is-disabled');
let todayEl = document.querySelector('.rdtDay.rdtToday')!;
let yesterdayEl = todayEl?.previousSibling!;
let tomorrowEl = todayEl?.nextSibling!;
if (yesterdayEl) {
fireEvent.click(yesterdayEl);
} else {
fireEvent.click(tomorrowEl);
}
wait(200);
/** 选择日期之后禁用消失 */
expect(getConfirmBtn()).not.toHaveClass('is-disabled');
fireEvent.click(getCancelBtn());
wait(200);
/** 取消之后重置值 */
expect(inputEl?.value).toEqual('');
fireEvent.click(trigger);
wait(200);
todayEl = document.querySelector('.rdtDay.rdtToday')!;
yesterdayEl = todayEl?.previousSibling!;
tomorrowEl = todayEl?.nextSibling!;
if (yesterdayEl) {
fireEvent.click(yesterdayEl);
} else {
fireEvent.click(tomorrowEl);
}
wait(200);
fireEvent.click(getConfirmBtn());
wait(200);
/** 确定之后有值 */
expect(inputEl?.value).not.toEqual('');
}, 7000);
/**
* CASE: 日期时间选择器首次选择日期或时间后,时间为默认值
* 前提条件:
* - 当前组件为input-datetime或者input-datetime-range类型
* - 当前组件未绑定值
* - 当前操作为首次编辑
* 预期:
* 1. 选择日期后,时间为默认值00:00:00
* 2. 选择时间后(H、m、s),所选择时间为点选值,其他时间为默认值00:00:00
* 3. 后续选择日期或者时间,不会改变点选值
* 4. 如果为范围选择器,先选择结束时间,则开始时间不能超过结束时间
*/
test('Renderer:InputDateTime Picker selects date or time for the first time', async () => {
const {container} = render(
amisRender(
{
type: 'form',
body: [
{
name: 'datetime',
label: '日期',
type: 'input-datetime',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
displayFormat: 'YYYY-MM-DD HH:mm:ss',
closeOnSelect: false
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const trigger = container.querySelector('.cxd-DatePicker')!;
const inputEl = (container.querySelector(
'.cxd-DatePicker-input'
) as HTMLInputElement)!;
const getConfirmBtn = () =>
container.querySelector(
'.cxd-DateRangePicker-actions > .cxd-Button.cxd-Button--primary'
)!;
expect(trigger).toBeInTheDocument();
fireEvent.click(trigger);
wait(200);
let todayEl = document.querySelector('.rdtDay.rdtToday')!;
let yesterdayEl = todayEl?.previousSibling!;
let tomorrowEl = todayEl?.nextSibling!;
const currentTime = new Date();
const currentSeconds = currentTime.getSeconds();
/** 跳过0秒,用于后续测试值和00:00:00的Diff */
if (currentSeconds === 0) {
wait(1000);
}
if (yesterdayEl) {
fireEvent.click(yesterdayEl);
} else {
fireEvent.click(tomorrowEl);
}
wait(200);
const timeStr = inputEl?.value?.split(/\s+/)?.[1];
/** 时间值设置为默认值 */
expect(timeStr === '00:00:00').toEqual(true);
fireEvent.click(todayEl);
wait(200);
const newTimeStr = inputEl?.value?.split(/\s+/)?.[1];
/** 切换日期后时间不会再变 */
expect(newTimeStr === timeStr).toEqual(true);
}, 7000);

View File

@@ -0,0 +1,227 @@
/**
* 组件名称:InputDatetimeRange 日期时间范围
*
* 备注:InputDatetimeRange 与 dateRange 等日期范围使用的是同一个组件,所以只测试不同的地方即可
*
* 单测内容:
1. 默认值
2. timeFormat 控制可以选择秒
3. inputFormat
4. 快捷键
*/
import {render, fireEvent, screen} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
const setup = async (items: any[] = []) => {
const onSubmit = jest.fn();
const utils = await render(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
await wait(200);
const submitBtn = utils.container.querySelector(
'button[type="submit"]'
) as HTMLElement;
const inputs = utils.container.querySelectorAll('.cxd-DateRangePicker-input');
function rerender(items: any[]) {
const onSubmit = jest.fn();
utils.rerender(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
}
return {
onSubmit,
submitBtn,
start: inputs[0],
end: inputs[1],
...utils,
rerender
};
};
// 1. 默认值
test('Renderer:datetimeRange with default', async () => {
const {container, start, end}: any = await setup([
{
type: 'input-datetime-range',
name: 'a',
label: 'date-range',
value: '1668115260,1668722939'
}
]);
expect(start.value).toEqual('2022-11-11 05:21');
expect(end.value).toEqual('2022-11-18 06:08');
// expect(container).toMatchSnapshot();
});
// 2. timeFormat 控制可以选择秒
test('Renderer:datetimeRange with displayFormat', async () => {
const {container, start, end}: any = await setup([
{
type: 'input-datetime-range',
name: 'select',
displayFormat: 'YYYY-MM-DD HH:mm:ss',
label: '日期时间范围',
value: '1668115260,1668722939'
}
]);
fireEvent.click(container.querySelector('.cxd-DateRangePicker-input'));
await wait(200);
expect(
container.querySelectorAll(
'.cxd-CalendarInputWrapper.cxd-CalendarInputWrapperMT'
).length
).toBe(3);
// expect(container).toMatchSnapshot();
});
// 3. inputFormat
test('Renderer:datetimeRange with timeFormat', async () => {
const {container, start, end}: any = await setup([
{
type: 'input-datetime-range',
name: 'select',
inputFormat: 'YYYY-MM-DD HH:mm:ss',
label: '日期时间范围',
value: '1667404800,1669270456'
}
]);
expect(start.value).toEqual('2022-11-03 00:00:00');
expect(end.value).toEqual('2022-11-24 14:14:16');
});
// 4. 快捷键
test('Renderer:datetimeRange with shortcuts', async () => {
const {container, start, end, getByText}: any = await setup([
{
type: 'input-datetime-range',
name: 'a',
label: '日期时间范围',
shortcuts: ['1hoursago', '2hourslater']
}
]);
fireEvent.click(start!);
await wait(200);
expect(getByText('最近1小时')).toBeInTheDocument();
expect(getByText('2小时以内')).toBeInTheDocument();
fireEvent.click(getByText('最近1小时'));
await wait(200);
expect(start.value).toEqual(
moment().add(-1, 'hour').format('YYYY-MM-DD HH:00')
);
expect(end.value).toEqual(
moment().add(-1, 'hour').format('YYYY-MM-DD HH:59')
);
fireEvent.click(start!);
await wait(200);
fireEvent.click(getByText('2小时以内'));
await wait(200);
expect(start.value).toEqual(moment().format('YYYY-MM-DD HH:00'));
expect(end.value).toEqual(moment().add(2, 'hour').format('YYYY-MM-DD HH:59'));
});
/**
* CASE: 日期时间选择器首次选择日期或时间后,时间自动设置为当前时间
* 预期:后续选择日期或者时间,不会改变点选值
*/
test('InputDateTimeRange Picker selects date or time for the first time', async () => {
const {container} = render(
amisRender({
type: 'form',
body: [
{
"type": "input-datetime-range",
"label": "日期时间范围",
"name": "begin",
"extraName": "end",
"valueFormat": "YYYY-MM-DD HH:mm:ss",
"displayFormat": "YYYY-MM-DD HH:mm:ss"
}
],
actions: []
}, {}, makeEnv({}))
);
const start = screen.getByPlaceholderText('开始时间') as HTMLInputElement;
const end = screen.getByPlaceholderText('结束时间');
fireEvent.click(start);
await wait(200);
let todayEl = document.querySelector('.rdtDay.rdtToday')!;
let yesterdayEl = todayEl?.previousSibling!;
let tomorrowEl = todayEl?.nextSibling!;
const currentTime = new Date();
const currentSeconds = currentTime.getSeconds();
/** 跳过0秒,用于后续测试值和00:00:00的Diff */
if (currentSeconds === 0) {
await wait(1000);
}
if (yesterdayEl) {
fireEvent.click(yesterdayEl);
}
else {
fireEvent.click(tomorrowEl);
}
await wait(200);
let timeStr = start?.value?.split(/\s+/)?.[1];
expect(timeStr.split?.(':')?.[0] !== '00').toEqual(true);
// 再次选择0点,预期切换成功
const hourSelector = container.querySelectorAll('.cxd-CalendarInput-sugsHours > .cxd-CalendarInput-sugsItem');
const zeroHour = hourSelector?.[0]!;
expect(hourSelector.length).toEqual(24);
expect(zeroHour?.textContent).toEqual('00');
fireEvent.click(zeroHour);
await wait(200);
timeStr = start?.value?.split(/\s+/)?.[1];
expect(timeStr.split?.(':')?.[0] === '00').toEqual(true);
}, 5000);

View File

@@ -0,0 +1,278 @@
/**
* 组件名称:FieldSet 表单项集合
*
* 单测内容:
* 1. 基本使用
* 2. mode
* 3. 可折叠 collapsable 和 默认是否折叠 collapsed
* 4. 标题位置 titlePosition、 收起标题 collapseTitle、展开标题 title
* 5. size
*/
import {render, fireEvent} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
// 1. 基本使用
test('Renderer:fieldSet', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'fieldSet',
name: 'a',
label: 'fieldSet',
mode: 'horizontal',
collapsable: true,
collapsed: false,
className: 'no-border',
headingClassName: 'bg-dark',
bodyClassName: 'bg-white',
horizontal: {
leftFixed: 1,
left: 4,
right: 7
},
controls: [
{
name: 'text',
type: 'text'
}
]
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
// 2. mode
test('Renderer:fieldSet with mode', async () => {
const schema = (mode: any) => ({
type: 'form',
api: '/api/xxx',
body: [
{
type: 'fieldSet',
name: 'a',
label: 'fieldSet',
mode,
body: [
{
name: 'text1',
type: 'input-text',
label: '文本1'
},
{
name: 'text2',
type: 'input-text',
label: '文本2'
}
]
}
],
title: 'The form',
actions: []
});
const {container, rerender} = render(
amisRender(schema('horizontal'), {}, makeEnv({}))
);
expect(container.querySelector('.cxd-Form--horizontal')!).toBeInTheDocument();
expect(container).toMatchSnapshot();
rerender(amisRender(schema('inline'), {}, makeEnv({})));
expect(container.querySelector('.cxd-Form--inline')!).toBeInTheDocument();
expect(container).toMatchSnapshot();
rerender(amisRender(schema('justify'), {}, makeEnv({})));
expect(container.querySelector('.cxd-Form--justify')!).toBeInTheDocument();
expect(container).toMatchSnapshot();
});
// 3. 可折叠 collapsable 和 默认是否折叠 collapsed
test('Renderer:fieldSet with collapsable & collapsed', async () => {
const {container, rerender} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'fieldSet',
name: 'a',
label: 'fieldSet',
collapsable: true,
title: 'header',
body: [
{
name: 'text1',
type: 'input-text',
label: '文本1'
},
{
name: 'text2',
type: 'input-text',
label: '文本2'
}
]
},
{
type: 'fieldSet',
name: 'b',
label: 'fieldSet2',
collapsable: true,
collapsed: true,
title: 'header',
body: [
{
name: 'text1',
type: 'input-text',
label: '文本1'
},
{
name: 'text2',
type: 'input-text',
label: '文本2'
}
]
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const header = container.querySelector('.cxd-Collapse-header')!;
expect(container.querySelector('.cxd-Collapse')!).toHaveClass('is-active');
expect(
container.querySelector('.cxd-Collapse:last-of-type')!
).not.toHaveClass('is-active');
fireEvent.click(header);
await wait(300);
expect(container.querySelector('.cxd-Collapse')!).not.toHaveClass(
'is-active'
);
});
// 4. 标题位置 titlePosition、 收起标题 collapseTitle、展开标题 title
test('Renderer:fieldSet with titlePosition & collapseTitle & title', async () => {
const {container, rerender} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'fieldSet',
name: 'a',
label: 'fieldSet',
collapsable: true,
title: '展开更多设置',
collapseTitle: '收起设置',
titlePosition: 'bottom',
body: [
{
name: 'text1',
type: 'input-text',
label: '文本1'
},
{
name: 'text2',
type: 'input-text',
label: '文本2'
}
]
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const item = container.querySelector('.cxd-Collapse.is-active')!;
expect(item).toHaveClass('cxd-Collapse--title-bottom');
expect(item.firstElementChild).toHaveClass('cxd-Collapse-contentWrapper');
expect(item.lastElementChild).toHaveTextContent('收起设置');
expect(container).toMatchSnapshot();
fireEvent.click(item.lastElementChild!);
await wait(400);
expect(item.lastElementChild).toHaveTextContent('展开更多设置');
});
// 5. size
test('Renderer:fieldSet with titlePosition & collapseTitle & title', async () => {
const schema = (size: any) => ({
type: 'form',
api: '/api/xxx',
body: [
{
type: 'fieldSet',
name: 'a',
label: 'fieldSet',
collapsable: true,
title: '展开更多设置',
size,
body: [
{
name: 'text1',
type: 'input-text',
label: '文本1'
},
{
name: 'text2',
type: 'input-text',
label: '文本2'
}
]
}
],
title: 'The form',
actions: []
});
const {container, rerender} = render(
amisRender(schema('xs'), {}, makeEnv({}))
);
expect(
container.querySelector('.cxd-Collapse.cxd-Collapse--xs')!
).toBeInTheDocument();
rerender(amisRender(schema('sm'), {}, makeEnv({})));
expect(
container.querySelector('.cxd-Collapse.cxd-Collapse--sm')!
).toBeInTheDocument();
rerender(amisRender(schema('base'), {}, makeEnv({})));
expect(
container.querySelector('.cxd-Collapse.cxd-Collapse--base')!
).toBeInTheDocument();
rerender(amisRender(schema('lg'), {}, makeEnv({})));
expect(
container.querySelector('.cxd-Collapse.cxd-Collapse--lg')!
).toBeInTheDocument();
rerender(amisRender(schema('xl'), {}, makeEnv({})));
expect(
container.querySelector('.cxd-Collapse.cxd-Collapse--xl')!
).toBeInTheDocument();
});

View File

@@ -0,0 +1,439 @@
import React = require('react');
import {render, fireEvent, cleanup} from '@testing-library/react';
import '../../../src';
import {render as amisRender, ValidateError} from '../../../src';
import {wait, makeEnv} from '../../helper';
import {clearStoresCache} from '../../../src';
import moment from 'moment';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:FormItem:validateApi:success', async () => {
const notify = jest.fn();
const onSubmit = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
controls: [
{
type: 'text',
name: 'a',
required: true,
label: 'Label',
validateApi: '/api/xxx'
}
],
title: 'The form',
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{
onSubmit
},
makeEnv({
notify,
fetcher
})
)
);
fireEvent.click(getByText('Submit'));
await wait(300);
expect(container).toMatchSnapshot();
expect(onSubmit).not.toHaveBeenCalled();
await wait(300);
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证', {
validateError: new ValidateError(
'依赖的部分字段没有通过验证',
{},
{
items: [],
msg: {
customMsg: '依赖的部分字段没有通过验证',
defaultMsg: '依赖的部分字段没有通过验证'
}
}
)
});
const input = container.querySelector('input[name=a]');
expect(input).toBeTruthy();
fireEvent.change(input!, {
target: {
value: '123'
}
});
await wait(500); // 有 250 秒左右的节流
fireEvent.click(getByText('Submit'));
await wait(300);
expect(onSubmit).toHaveBeenCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
});
test('Renderer:FormItem:validateApi:failed', async () => {
const notify = jest.fn();
const onSubmit = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 422,
msg: '',
errors: '用户名已存在'
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
controls: [
{
type: 'text',
name: 'a',
required: true,
label: 'Label',
validateApi: '/api/xxx'
}
],
title: 'The form',
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{
onSubmit
},
makeEnv({
notify,
fetcher
})
)
);
fireEvent.click(getByText('Submit'));
await wait(300);
expect(container).toMatchSnapshot();
expect(onSubmit).not.toHaveBeenCalled();
await wait(300);
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证', {
validateError: new ValidateError(
'依赖的部分字段没有通过验证',
{},
{
items: [],
msg: {
customMsg: '依赖的部分字段没有通过验证',
defaultMsg: '依赖的部分字段没有通过验证'
}
}
)
});
const input = container.querySelector('input[name=a]');
expect(input).toBeTruthy();
fireEvent.change(input!, {
target: {
value: '123'
}
});
await wait(500); // 有 250 秒左右的节流
fireEvent.click(getByText('Submit'));
await wait(300);
expect(onSubmit).not.toHaveBeenCalled();
expect(container).toMatchSnapshot();
});
test('Renderer:FormItem:extraName', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
id: 'theform',
body: [
{
type: 'input-date-range',
format: 'YYYY-MM-DD',
name: 'begin',
extraName: 'end',
label: 'Label'
}
],
title: 'The form',
actions: [
{
type: 'button',
label: 'ChangeValue',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'theform',
args: {
value: {
end: `${moment().format('YYYY-MM')}-16`
}
}
}
]
}
}
},
{
type: 'submit',
label: 'Submit'
}
]
},
{
onSubmit
},
makeEnv({})
)
);
// 打开弹框
fireEvent.click(
container.querySelector('.cxd-DateRangePicker-input') as HTMLElement
);
await wait(200);
// 点击选择
fireEvent.click(
container.querySelector(
'.cxd-DateRangePicker-popover tr td[data-value="15"]'
) as HTMLElement
);
// 点击选择
fireEvent.click(
container.querySelector(
'.cxd-DateRangePicker-popover tr td[data-value="15"]'
) as HTMLElement
);
fireEvent.click(getByText('确认'));
fireEvent.click(getByText('Submit'));
await wait(300);
expect(onSubmit).toBeCalledTimes(1);
expect(onSubmit.mock.calls[0][0]).toMatchObject({
begin: `${moment().format('YYYY-MM')}-15`,
end: `${moment().format('YYYY-MM')}-15`
});
fireEvent.click(getByText('ChangeValue'));
await wait(200);
expect(
(container.querySelector('input[placeholder="结束时间"]') as any).value
).toBe(`${moment().format('YYYY-MM')}-16`);
fireEvent.click(getByText('Submit'));
await wait(300);
expect(onSubmit).toBeCalledTimes(2);
expect(onSubmit.mock.calls[1][0]).toMatchObject({
begin: `${moment().format('YYYY-MM')}-15`,
end: `${moment().format('YYYY-MM')}-16`
});
});
test('Renderer:FormItem:dynamicName', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
id: 'theform',
submitText: 'Submit',
body: [
{
type: 'input-text',
name: '${a}',
label: 'Label'
}
],
title: 'The form'
},
{
onSubmit,
data: {
a: 'abc'
}
},
makeEnv({})
)
);
const input = container.querySelector('input[name=abc]');
expect(input).toBeTruthy();
fireEvent.change(input!, {
target: {
value: '123'
}
});
await wait(500); // 有 250 秒左右的节流
fireEvent.click(getByText('Submit'));
await wait(300);
expect(onSubmit).toHaveBeenCalled();
expect(onSubmit.mock.calls[0][0]).toMatchObject({
abc: '123'
});
});
test('Renderer:FormItem:label with variable', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
id: 'theform',
submitText: 'Submit',
body: [
{
type: 'input-text',
name: 'b',
label: 'Label ${a}'
}
],
title: 'The form'
},
{
onSubmit,
data: {
a: '${b}',
b: '123'
}
},
makeEnv({})
)
);
await wait(200);
const label = container.querySelector('label');
expect(label?.innerHTML).toBe(
'<span><span class="cxd-TplField fr-view"><span>Label ${b}</span></span></span>'
);
});
test('Renderer:FormItem:disabledInTabs', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
id: 'theform',
submitText: 'Submit',
body: [
{
type: 'tabs',
disabled: false,
tabs: [
{
title: 'Tab1',
body: [
{
type: 'input-text',
name: 'a',
disabled: true
}
]
},
{
title: 'Tabb',
disabled: true,
body: [
{
type: 'input-text',
name: 'b'
}
]
}
]
}
]
},
{},
makeEnv({})
)
);
await wait(200);
expect(container.querySelector('input[name=a]')).toBeDisabled();
expect(container.querySelector('input[name=b]')).toBeDisabled();
});
test('Renderer:Formitem initial value in table', async () => {
const {container, getByText} = render(
amisRender(
{
type: 'table',
source: '${items}',
columns: [
{
type: 'property',
items: [
{
label: 'A',
content: {
type: 'input-tag',
name: 'a',
static: true
}
}
]
}
]
},
{
data: {
items: [{a: '123'}]
}
},
makeEnv({})
)
);
expect(container.innerHTML).toContain('123');
});
// TODO 补充测试用例
// https://github.com/baidu/amis/issues/9742
// https://github.com/baidu/amis/issues/9733

View File

@@ -0,0 +1,100 @@
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';
test('Renderer:formula', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'number',
name: 'a',
label: 'a'
},
{
type: 'number',
name: 'b',
label: 'b'
},
{
type: 'number',
name: 'sum1',
label: 'sum1'
},
{
type: 'number',
name: 'sum2',
label: 'sum2'
},
{
type: 'number',
name: 'sum3',
label: 'sum3'
},
{
type: 'number',
name: 'sum4',
label: 'sum4'
},
{
type: 'formula',
name: 'sum1',
value: 0,
formula: 'a + b'
},
{
type: 'formula',
name: 'sum2',
condition: '${b}',
value: 0,
formula: 'a + b + 1'
},
{
type: 'formula',
name: 'sum3',
condition: 'data.b',
value: 0,
formula: 'a + b + 2'
},
{
type: 'formula',
name: 'sum4',
condition: 'data.b',
value: 0,
formula: '${a + b + 2}'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const inputs = container.querySelectorAll('input[role="spinbutton"]') as any;
fireEvent.change(inputs[0], {
target: {
value: 1
}
});
fireEvent.change(inputs[1], {
target: {
value: 2
}
});
await wait(300);
await waitFor(() => {
expect(inputs[2].value).toBe('3');
expect(inputs[3].value).toBe('4');
expect(inputs[4].value).toBe('5');
expect(inputs[5].value).toBe('5');
});
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,52 @@
import React = require('react');
import {render, cleanup} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:hbox', async () => {
const {container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'grid',
columns: [
{
md: 3,
mdOffset: 1,
columnClassName: 'bg-white',
controls: [
{
name: 'text',
type: 'text',
label: false,
placeholder: 'Text'
}
]
},
{
md: 9,
type: 'tpl',
tpl: '其他渲染器类型'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,90 @@
import React = require('react');
import {render, cleanup} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:group', async () => {
const {container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'group',
mode: 'horizontal',
className: 'bg-white',
horizontal: {
label: 1,
right: 10,
offset: 1
},
controls: [
{
type: 'text',
name: 'test1',
label: 'Label',
placeholder: 'Placeholder'
},
{
type: 'text',
name: 'test2',
label: 'Label',
placeholder: 'Placeholder'
}
]
},
{
type: 'group',
mode: 'inline',
className: 'bg-white',
controls: [
{
type: 'text',
name: 'test1',
label: 'Label',
placeholder: 'Placeholder'
},
{
type: 'text',
name: 'test2',
label: 'Label',
placeholder: 'Placeholder'
}
]
},
{
type: 'group',
direction: 'vertical',
controls: [
{
type: 'text',
name: 'test1',
label: 'Label',
placeholder: 'Placeholder'
},
{
type: 'text',
name: 'test2',
label: 'Label',
placeholder: 'Placeholder'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,49 @@
import React = require('react');
import {render, cleanup} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:hbox', async () => {
const {container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'hbox',
columns: [
{
columnClassName: 'w-sm',
controls: [
{
name: 'text',
type: 'text',
label: false,
placeholder: 'Text'
}
]
},
{
type: 'tpl',
tpl: '其他类型的渲染器'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,63 @@
import React = require('react');
import {fireEvent, render} from '@testing-library/react';
import '../../../src';
import {render as amisRender, setIconVendor} from '../../../src';
import {makeEnv, replaceReactAriaIds, wait} from '../../helper';
test('Renderer:icon-picker', async () => {
const vendors = [
{
name: 'Font Awesome 4.7',
prefix: 'fa fa-',
icons: ['address-book', 'address-book-o', 'address-card']
},
{
name: 'Glyphicons',
prefix: 'glyphicon glyphicon-',
icons: ['asterisk', 'plus', 'euro', 'eur', 'minus']
}
];
setIconVendor(vendors);
const {container, findByText, getByTitle} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'icon-picker',
name: 'a',
label: 'icon-picker',
value: 'address-card'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const faIcon = container.querySelector('.cxd-IconPickerControl-value');
expect(faIcon?.innerHTML.replace(/<\s*i[^>]*><\s*\/\s*i>/g, '')).toEqual(
'address-card'
);
const input = container.querySelector('input[name="a"]') as any;
fireEvent.focus(input!);
fireEvent.click(await findByText(/Glyphicons/));
fireEvent.change(input!, {
target: {
value: 'glyphicon glyphicon-plus'
}
});
fireEvent.click(container.querySelector('.glyphicon-plus')!);
await wait(500);
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,594 @@
import {render, fireEvent, cleanup, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender, ValidateError} from '../../../src';
import {wait, makeEnv} from '../../helper';
import {clearStoresCache} from '../../../src';
// mock getComputedStyle
Object.defineProperty(window, 'getComputedStyle', {
value: () => ({
getPropertyValue: (prop: any) => {
return '';
}
})
});
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:Form', async () => {
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok'
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'text',
name: 'a',
label: 'Label',
value: '123'
}
],
title: 'The form',
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{},
makeEnv({
fetcher
})
)
);
expect(container).toMatchSnapshot();
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(fetcher).toHaveBeenCalled();
expect(fetcher.mock.calls[0][0]).toMatchSnapshot();
});
});
test('Renderer:Form:valdiate', async () => {
const notify = jest.fn();
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
controls: [
{
type: 'text',
name: 'a',
required: true,
label: 'Label'
}
],
title: 'The form',
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{
onSubmit
},
makeEnv({
notify
})
)
);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(container.querySelector('.cxd-Form-feedback')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
expect(onSubmit).not.toHaveBeenCalled();
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证', {
validateError: new ValidateError(
'依赖的部分字段没有通过验证',
{},
{
items: [],
msg: {
customMsg: '依赖的部分字段没有通过验证',
defaultMsg: '依赖的部分字段没有通过验证'
}
}
)
});
const input = container.querySelector('input[name=a]');
expect(input).toBeTruthy();
fireEvent.change(input!, {
target: {
value: '123'
}
});
await waitFor(() => {
expect(
container.querySelector('input[name=a][value="123"]')
).toBeInTheDocument();
});
fireEvent.click(getByText('Submit'));
expect(container).toMatchSnapshot();
await waitFor(() => {
expect(onSubmit).toHaveBeenCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
});
});
test('Renderer:Form:remoteValidate', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 422,
msg: '服务端验证失败',
errors: {
a: '这个字段服务端验证失败'
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'text',
name: 'a',
label: 'Label'
}
],
title: 'The form',
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{},
makeEnv({
notify,
fetcher
})
)
);
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(container.querySelector('.cxd-Form-feedback')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('Renderer:Form:onValidate', async () => {
const notify = jest.fn();
const onSubmit = jest.fn();
const onValidate = jest
.fn()
.mockImplementationOnce(() => ({
a: 'a is wrong',
b: ['b is wrong', 'b is wrong 2']
}))
.mockImplementationOnce(() => ({
a: '',
b: ''
}));
const {container, getByText} = render(
amisRender(
{
type: 'form',
controls: [
{
type: 'text',
name: 'a',
label: 'A',
value: 1
},
{
type: 'text',
name: 'b',
label: 'B',
value: 2
}
],
title: 'The form',
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{
onSubmit,
onValidate
},
makeEnv({
notify
})
)
);
await waitFor(() => {
expect(getByText('Submit')).toBeInTheDocument();
});
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(container.querySelector('.cxd-Form-feedback')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
expect(onSubmit).not.toHaveBeenCalled();
expect(onValidate).toHaveBeenCalled();
expect(onValidate.mock.calls[0][0]).toMatchSnapshot();
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证', {
validateError: new ValidateError(
'依赖的部分字段没有通过验证',
{},
{
items: [],
msg: {
customMsg: '依赖的部分字段没有通过验证',
defaultMsg: '依赖的部分字段没有通过验证'
}
}
)
});
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(
container.querySelector('.cxd-Form-feedback')
).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
expect(onSubmit).toHaveBeenCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
});
test('Renderer:Form initApi', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
data: {
a: 1,
b: 2
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: '/api/xxx',
controls: [
{
type: 'text',
name: 'a',
label: 'A'
},
{
type: 'text',
name: 'b',
label: 'B'
}
],
title: 'The form'
},
{},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
container.querySelector('[name="a"][value="1"]')
).toBeInTheDocument();
});
// fetch 调用了,所有 initApi 接口调用了
expect(fetcher).toHaveBeenCalled();
// 通过 snapshot 可断定 initApi 返回值已经作用到了表单项上。
expect(container).toMatchSnapshot();
});
test('Renderer:Form initFetch:false', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
data: {
a: 1,
b: 2
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: '/api/xxx',
initFetch: false,
controls: [
{
type: 'text',
name: 'a',
label: 'A'
},
{
type: 'text',
name: 'b',
label: 'B'
}
],
title: 'The form'
},
{},
makeEnv({
notify,
fetcher
})
)
);
expect(fetcher).not.toHaveBeenCalled();
});
test('Renderer:Form initFetchOn:false', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
data: {
a: 1,
b: 2
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: '/api/xxx',
initFetchOn: 'this.goFetch',
controls: [
{
type: 'text',
name: 'a',
label: 'A'
},
{
type: 'text',
name: 'b',
label: 'B'
}
],
title: 'The form'
},
{
data: {
goFetch: false
}
},
makeEnv({
notify,
fetcher
})
)
);
expect(fetcher).not.toHaveBeenCalled();
});
test('Renderer:Form sendOn:false', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
data: {
a: 1,
b: 2
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: {
method: 'get',
url: '/api/xxx',
sendOn: 'this.goFetch'
},
controls: [
{
type: 'text',
name: 'a',
label: 'A'
},
{
type: 'text',
name: 'b',
label: 'B'
}
],
title: 'The form'
},
{
data: {
goFetch: false
}
},
makeEnv({
notify,
fetcher
})
)
);
expect(fetcher).not.toHaveBeenCalled();
});
test('Renderer:Form sendOn:true', async () => {
const notify = jest.fn();
const fetcher = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
data: {
a: 1,
b: 2
}
}
})
);
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: {
method: 'get',
url: '/api/xxx',
sendOn: 'this.goFetch'
},
controls: [
{
type: 'text',
name: 'a',
label: 'A'
},
{
type: 'text',
name: 'b',
label: 'B'
}
],
title: 'The form'
},
{
data: {
goFetch: true
}
},
makeEnv({
notify,
fetcher
})
)
);
await waitFor(() => {
expect(
container.querySelector('[name="a"][value="1"]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
expect(fetcher).toHaveBeenCalled();
expect(container).toMatchSnapshot();
});
test('Renderer:Form reset', async () => {
const pristineData = {
email: 'user@baidu.com'
};
const onReset = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名'
},
{
type: 'input-email',
name: 'email',
label: '邮箱',
value: pristineData.email
}
],
actions: [
{
type: 'reset',
label: 'ResetButton'
},
{
type: 'submit',
label: 'SubmitBtn'
}
]
},
{onReset},
makeEnv({})
)
);
const textInput = container.querySelector(
'input[name="name"]'
) as HTMLInputElement;
const emailInput = container.querySelector(
'input[name="email"]'
) as HTMLInputElement;
expect(textInput).toBeInTheDocument();
expect(emailInput).toBeInTheDocument();
fireEvent.change(textInput, {target: {value: 'username'}});
fireEvent.change(emailInput, {target: {value: 'user_changed@baidu.com'}});
fireEvent.click(getByText('ResetButton'));
await waitFor(() => {
expect(onReset).toHaveBeenCalled();
expect(onReset).toHaveBeenCalledWith(pristineData);
});
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,328 @@
import React = require('react');
import {render, cleanup, fireEvent, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Form:initData', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
wrapWithPanel: false,
body: [
{
type: 'input-text',
name: 'a',
value: '1'
},
{
type: 'input-text',
name: 'b',
value: '2'
},
{
type: 'submit',
label: 'Submit'
}
]
},
{
onSubmit
},
makeEnv()
)
);
await waitFor(() => {
expect(
container.querySelector('[name="a"][value="1"]')
).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/Submit/));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
});
});
test('Form:initData:super', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'page',
data: {
a: 1,
b: 2
},
body: {
type: 'form',
title: 'The form',
wrapWithPanel: false,
onSubmit,
body: [
{
type: 'input-text',
name: 'a'
},
{
type: 'input-text',
name: 'b'
},
{
type: 'submit',
label: 'Submit'
}
]
}
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/Submit/));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchInlineSnapshot(`
{
"a": 1,
"b": 2,
}
`);
});
});
test('Form:initData:without-super', async () => {
const onSubmit = jest.fn();
const {container, getByText} = render(
amisRender(
{
type: 'page',
data: {
a: 1,
b: 2
},
body: {
type: 'form',
title: 'The form',
wrapWithPanel: false,
onSubmit,
canAccessSuperData: false,
body: [
{
type: 'input-text',
name: 'a'
},
{
type: 'input-text',
name: 'b'
},
{
type: 'submit',
label: 'Submit'
}
]
}
},
{},
makeEnv()
)
);
// 这个应该是不能设置上初始值的
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/Submit/));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
});
});
test('Form:initData:remote', async () => {
const resultPromise = Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
a: 1,
b: 2
}
}
});
const onSubmit = jest.fn();
const fetcher = jest.fn().mockImplementation(() => resultPromise);
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: '/api/xxx?c=${c}',
controls: [
{
type: 'text',
name: 'a',
label: 'Label'
},
{
type: 'text',
name: 'c',
label: 'Label',
value: '123'
}
],
title: 'The form',
onSubmit,
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{},
makeEnv({
fetcher
})
)
);
await waitFor(() => {
expect(
container.querySelector('[name="a"][value="1"]')
).toBeInTheDocument();
expect(
container.querySelector('[name="c"][value="123"]')
).toBeInTheDocument();
expect(
container.querySelector('[data-testid="spinner"]')
).not.toBeInTheDocument();
});
expect(container).toMatchSnapshot();
expect(fetcher).toHaveBeenCalled();
expect(fetcher.mock.calls[0][0]).toMatchSnapshot();
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
});
});
// 主要用来测试 form 的 source 接口是否在 initApi 后调用
// 并且发送的参数是否可以携带 initApi 返回的数据
// 并且 source 接口如果返回了 value 是否可以应用上。
test('Form:initData:remote:options:source', async () => {
const fetcherinitApi = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
id: 1
}
}
})
);
const fetcherSourceApi = jest.fn().mockImplementation(() =>
Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
value: 'b',
options: [
{
label: 'OptionA',
value: 'a'
},
{
label: 'OptionB',
value: 'b'
}
]
}
}
})
);
const onSubmit = jest.fn();
const fetcher = (arg1: any, ...rest: Array<any>) => {
const api = /\/api\/(\w+)/.test(arg1.url) ? RegExp.$1 : '';
const map: any = {
initApi: fetcherinitApi,
source: fetcherSourceApi
};
return map[api](arg1, ...rest);
};
const {container, getByText} = render(
amisRender(
{
type: 'form',
initApi: '/api/initApi?op=${op}',
controls: [
{
type: 'hidden',
name: 'op',
value: 'init'
},
{
type: 'select',
name: 'a',
label: 'Select',
source: '/api/source?id=${id}'
}
],
title: 'The form',
onSubmit,
actions: [
{
type: 'submit',
label: 'Submit'
}
]
},
{},
makeEnv({
fetcher
})
)
);
await waitFor(async () => {
expect(getByText('OptionB')).toBeInTheDocument();
expect(fetcherinitApi).toHaveBeenCalled();
expect(fetcherinitApi.mock.calls[0][0].url).toEqual('/api/initApi?op=init');
await wait(200); // 只有出现在 waitFor 里面的才有用。
});
fireEvent.click(getByText('Submit'));
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchObject({
id: 1,
op: 'init',
a: 'b'
});
});
});

View File

@@ -0,0 +1,245 @@
/**
* 组件名称:InputArray 数组输入框
* 单测内容:
* 1. 修改组件内容 value
* 2. 是否可删除 removable、是否可新增 addable 与 新增按钮文字 addButtonText
* 3. 输入最小长度 minLength 与 最大长度 maxLength
* 4. 是否可拖拽排序 draggable 与 可拖拽的提示文字 draggableTip
*/
import React from 'react';
import {render, fireEvent, waitFor, screen} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
const setup = async (items: any[] = []) => {
const onSubmit = jest.fn();
const utils = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
const submitBtn = utils.container.querySelector(
'button[type="submit"]'
) as HTMLElement;
return {
onSubmit,
submitBtn,
...utils
};
};
test('Renderer:inputArray', async () => {
const onSubmit = jest.fn();
const submitBtnText = 'Submit';
const {container, findByText} = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: submitBtnText,
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: [
{
name: 'array',
label: '颜色集合',
type: 'input-array',
inline: true,
items: {
type: 'input-text',
clearable: false
}
}
]
}
},
{onSubmit},
makeEnv({})
)
);
const addButton = await findByText('新增');
fireEvent.click(addButton);
await waitFor(() => {
const input = container.querySelector('.cxd-TextControl-input input')!;
fireEvent.change(input, {target: {value: 'amis'}});
});
const submitBtn = screen.getByRole('button', {name: submitBtnText});
await waitFor(() => {
expect(submitBtn).toBeInTheDocument();
});
fireEvent.click(submitBtn);
await waitFor(() => {
const formData = onSubmit.mock.calls[0][0];
expect(onSubmit).toHaveBeenCalled();
expect(formData).toEqual({
array: ['amis']
});
});
expect(container).toMatchSnapshot();
});
test('Renderer:inputArray with removable & addable & addButtonText', async () => {
const {container: containerOne} = await setup([
{
name: 'array',
label: '颜色集合',
type: 'input-array',
inline: true,
removable: false,
addable: false,
items: {
type: 'input-text'
},
value: ['red', 'blue']
}
]);
await wait(300);
await waitFor(() => {
expect(
containerOne.querySelector('.cxd-Combo-delBtn')
).not.toBeInTheDocument();
expect(
containerOne.querySelector('.cxd-Combo-addBtn')
).not.toBeInTheDocument();
expect(containerOne).toMatchSnapshot('false');
});
const {container, onSubmit, submitBtn} = await setup([
{
name: 'array',
label: '颜色集合',
type: 'input-array',
inline: true,
removable: true,
addable: true,
items: {
type: 'input-text'
},
value: ['red', 'blue'],
addButtonText: '我是增加按钮'
}
]);
await wait(300);
const delButton = container.querySelector('a.cxd-Combo-delBtn');
expect(container.querySelectorAll('a.cxd-Combo-delBtn').length).toBe(2);
const addButton = container.querySelector('.cxd-Combo-addBtn')!;
expect(delButton).toBeInTheDocument();
expect(addButton).toBeInTheDocument();
expect((addButton.querySelector('span') as Element).innerHTML).toBe(
'我是增加按钮'
);
fireEvent.click(delButton!);
await wait(300);
fireEvent.click(submitBtn);
await waitFor(() => {
const formData = onSubmit.mock.calls[0][0];
expect(onSubmit).toHaveBeenCalled();
expect(formData).toEqual({
array: ['blue']
});
});
expect(container).toMatchSnapshot('false');
}, 10000);
test('Renderer:inputArray with minLength & maxLength', async () => {
const {container} = await setup([
{
name: 'array',
label: '颜色集合',
type: 'input-array',
inline: true,
removable: true,
addable: true,
minLength: 2,
maxLength: 4,
items: {
type: 'input-text'
},
value: ['red', 'blue', 'green']
}
]);
await wait(300);
// 范围内的,增删都在
expect(container.querySelector('a.cxd-Combo-delBtn')).toBeInTheDocument();
expect(container.querySelector('.cxd-Combo-addBtn')).toBeInTheDocument();
// 最大值
fireEvent.click(container.querySelector('.cxd-Combo-addBtn')!);
await wait(300);
await waitFor(() => {
expect(container.querySelector('a.cxd-Combo-delBtn')).toBeInTheDocument();
expect(
container.querySelector('.cxd-Combo-addBtn')
).not.toBeInTheDocument();
});
// 最小值
fireEvent.click(container.querySelector('a.cxd-Combo-delBtn')!);
await wait(300);
fireEvent.click(container.querySelector('a.cxd-Combo-delBtn')!);
await waitFor(() => {
expect(
container.querySelector('a.cxd-Combo-delBtn')
).not.toBeInTheDocument();
expect(container.querySelector('.cxd-Combo-addBtn')).toBeInTheDocument();
});
expect(container).toMatchSnapshot();
});
test('Renderer:inputArray with draggable & draggableTip', async () => {
const {container, onSubmit, submitBtn} = await setup([
{
name: 'array',
label: '颜色集合',
type: 'input-array',
inline: true,
draggable: true,
draggableTip: '我是拖拽提示',
items: {
type: 'input-text'
},
value: ['red', 'blue', 'green']
}
]);
await wait(500);
const drager = container.querySelector('.cxd-Combo-itemDrager')!;
expect(drager).toBeInTheDocument();
expect(container.querySelectorAll('.cxd-Combo-itemDrager').length).toBe(3);
expect(container.querySelector('.cxd-Combo-dragableTip')).toBeInTheDocument();
expect(
(container.querySelector('.cxd-Combo-dragableTip') as Element).innerHTML
).toBe('我是拖拽提示');
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,237 @@
/**
* 组件名称:InputCity 城市选择器
* 单测内容:
* 1. 基础使用
* 2. searchable
* 3. allowDistrict & allowCity
*/
import {
render,
fireEvent,
cleanup,
getByText,
within,
waitFor
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, replaceReactAriaIds, wait} from '../../helper';
const setup = async (items: any[] = []) => {
const onSubmit = jest.fn();
const utils = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
const submitBtn = utils.container.querySelector(
'button[type="submit"]'
) as HTMLElement;
return {
onSubmit,
submitBtn,
...utils,
rerender: (items: any[]) =>
utils.rerender(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
)
};
};
// 1. 基础使用
test('Renderer:inputCity', async () => {
const {container, getByText, onSubmit, submitBtn} = await setup([
{
name: 'city',
type: 'input-city',
label: '城市'
}
]);
await wait(100);
const select = container.querySelector('.cxd-CityPicker > .cxd-Select')!;
expect(select).toBeInTheDocument();
fireEvent.click(select);
expect(getByText('北京市')).toBeInTheDocument();
fireEvent.click(getByText('北京市'));
await wait(100);
fireEvent.click(submitBtn);
await waitFor(() => {
expect(onSubmit).toBeCalled();
expect(onSubmit.mock.calls[0][0]).toMatchObject({
city: '110000'
});
});
const select2 = container.querySelector(
'.cxd-CityPicker > .cxd-Select:nth-child(2)'
)!;
expect(select2).toBeInTheDocument();
fireEvent.click(select2);
expect(getByText('北京市市辖区')).toBeInTheDocument();
fireEvent.click(getByText('北京市市辖区'));
await wait(100);
fireEvent.click(submitBtn);
await waitFor(() => {
expect(onSubmit).toBeCalledTimes(2);
expect(onSubmit.mock.calls[1][0]).toMatchObject({
city: '110100'
});
});
const select3 = container.querySelector(
'.cxd-CityPicker > .cxd-Select:nth-child(3)'
)!;
expect(select3).toBeInTheDocument();
fireEvent.click(select3);
expect(getByText('海淀区')).toBeInTheDocument();
fireEvent.click(getByText('海淀区'));
await wait(500);
fireEvent.click(submitBtn);
await waitFor(() => {
expect(onSubmit).toBeCalledTimes(3);
expect(onSubmit.mock.calls[2][0]).toMatchObject({
city: '110108'
});
});
await wait(200);
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
}, 10000);
// 2. searchable
test('Renderer:inputCity with searchable', async () => {
const {container, getByText, onSubmit, submitBtn, getByTitle} = await setup([
{
name: 'city',
type: 'input-city',
label: '城市',
searchable: true
}
]);
await wait(100);
const select = container.querySelector('.cxd-CityPicker > .cxd-Select')!;
expect(select).toBeInTheDocument();
fireEvent.click(select);
await wait(100);
replaceReactAriaIds(container);
expect(container).toMatchSnapshot('open select');
const input = select.querySelector('.cxd-Select-input input')!;
expect(input).toBeInTheDocument();
fireEvent.change(input, {target: {value: '山'}});
await wait(100);
expect(
select.querySelectorAll('.cxd-Select-menu > .cxd-Select-option')!.length
).toBe(2);
expect(
await within(select as HTMLElement).getByTitle('山东省')
).toBeInTheDocument();
expect(
await within(select as HTMLElement).getByTitle('山西省')
).toBeInTheDocument();
});
// 3. allowDistrict & allowCity
test('Renderer:inputCity with allowDistrict & allowCity', async () => {
const {container, getByText, onSubmit, submitBtn, getByTitle, rerender} =
await setup([
{
name: 'city',
type: 'input-city',
label: '城市',
allowDistrict: false,
allowCity: false
}
]);
await wait(100);
const select = container.querySelector('.cxd-CityPicker > .cxd-Select')!;
expect(select).toBeInTheDocument();
fireEvent.click(select);
expect(getByText('北京市')).toBeInTheDocument();
fireEvent.click(getByText('北京市'));
await wait(100);
expect(
container.querySelector('.cxd-CityPicker > .cxd-Select:nth-child(2)')!
).not.toBeInTheDocument();
rerender([
{
name: 'city',
type: 'input-city',
label: '城市',
allowDistrict: false,
allowCity: true
}
]);
fireEvent.click(select);
expect(getByText('山西省')).toBeInTheDocument();
fireEvent.click(getByText('山西省'));
await wait(100);
const select2 = container.querySelector(
'.cxd-CityPicker > .cxd-Select:nth-child(2)'
)!;
expect(select2).toBeInTheDocument();
fireEvent.click(select2);
expect(getByText('太原市')).toBeInTheDocument();
fireEvent.click(getByText('太原市'));
await wait(100);
expect(
container.querySelector('.cxd-CityPicker > .cxd-Select:nth-child(3)')!
).not.toBeInTheDocument();
rerender([
{
name: 'city',
type: 'input-city',
label: '城市',
allowDistrict: true,
allowCity: true
}
]);
fireEvent.click(select2);
expect(getByText('忻州市')).toBeInTheDocument();
fireEvent.click(getByText('忻州市'));
await wait(100);
expect(
container.querySelector('.cxd-CityPicker > .cxd-Select:nth-child(3)')!
).toBeInTheDocument();
});

View File

@@ -0,0 +1,589 @@
/**
* 组件名称:InputDate 日期
* 单测内容:
* 1. 点击选择日期
* 2. 内嵌模式 embed
* 3. 值格式 valueFormat 与 显示格式 displayFormat
* 4. 范围限制 最小值 minDate, 最大值 maxDate
* 5. 默认值 value 支持 相对值 写法
* 6. 日期快捷选项 shortcuts
* 7. 可清除 clearable
*/
import React from 'react';
import PageRenderer from '../../../../amis-core/src/renderers/Form';
import * as renderer from 'react-test-renderer';
import {
render,
fireEvent,
cleanup,
getByText,
waitFor,
screen
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
const setup = async (items: any[] = []) => {
const onSubmit = jest.fn();
const utils = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
const submitBtn = utils.container.querySelector(
'button[type="submit"]'
) as HTMLElement;
return {
onSubmit,
submitBtn,
...utils
};
};
test('Renderer:inputDate', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'input-date',
name: 'a',
label: 'date',
value: '1559836800',
minDate: '1559664000',
maxDate: '1561737600'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const input = container.querySelector(
'.cxd-DatePicker input'
)! as HTMLInputElement;
expect(input.value).toEqual(moment(1559836800, 'X').format('YYYY-MM-DD'));
expect(container).toMatchSnapshot();
});
test('Renderer:inputDate click', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
api: '/api/mock2/form/saveForm',
body: [
{
type: 'static-date',
name: 'date',
label: '当前值'
},
{
type: 'input-date',
name: 'date',
label: '日期'
}
]
}
},
{},
makeEnv({})
)
);
const inputDate = container.querySelector('.cxd-DatePicker') as HTMLElement;
fireEvent.click(inputDate);
// 点击前一年
fireEvent.click(
container.querySelector('.cxd-DatePicker-popover .rdtPrev') as HTMLElement
);
// 点击下一个月
fireEvent.click(
container.querySelector('.cxd-DatePicker-popover .rdtNext') as HTMLElement
);
const date = container.querySelector(
'.cxd-DatePicker-popover tr td[data-value="1"]'
) as HTMLElement;
fireEvent.click(date);
const tpl = container.querySelector('.cxd-DateField') as HTMLElement;
expect(tpl.innerHTML).toEqual(
moment().subtract(1, 'year').add(1, 'month').format('YYYY-MM') + '-01'
);
});
test('Renderer:inputDate embed', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
api: '/api/mock2/form/saveForm',
body: [
{
type: 'static-date',
name: 'date',
label: '当前值'
},
{
type: 'input-date',
name: 'date',
label: '日期',
embed: true
}
]
}
},
{},
makeEnv({})
)
);
const date = container.querySelector(
'.cxd-DateCalendar tr td[data-value="1"]'
) as HTMLElement;
fireEvent.click(date);
const tpl = container.querySelector('.cxd-DateField') as HTMLElement;
expect(tpl.innerHTML).toEqual(moment().format('YYYY-MM') + '-01');
});
test('Renderer:inputDate with valueFormat & displayFormat', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
value: '2022/08/19',
displayFormat: 'DD/MM-YYYY',
valueFormat: '今天是YYYY年, MM月, DD日'
},
{
type: 'static',
name: 'date'
}
]);
const tpl = container.querySelector('.cxd-PlainField')! as HTMLElement;
const input = container.querySelector(
'.cxd-DatePicker input'
)! as HTMLInputElement;
expect(tpl.innerHTML).toEqual('今天是2022年, 08月, 19日');
expect(input.value).toEqual('19/08-2022');
expect(container).toMatchSnapshot();
});
test('Renderer:inputDate compatible with format & inputFormat', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date1',
label: '日期',
value: '2022/08/19',
inputFormat: 'DD/MM-YYYY',
format: '今天是YYYY年, MM月, DD日'
},
{
type: 'static',
name: 'date1'
},
{
type: 'input-date',
name: 'date2',
label: '日期',
value: '2022/08/19',
inputFormat: 'DD/MM-YYYY',
format: '今天是YYYY年, MM月, DD日'
},
{
type: 'static',
name: 'date2'
}
]);
const tpl = container.querySelectorAll(
'.cxd-PlainField'
)! as NodeListOf<Element>;
const input = container.querySelectorAll(
'.cxd-DatePicker-input'
)! as NodeListOf<HTMLInputElement>;
expect(tpl[0].innerHTML).toEqual(tpl[1].innerHTML);
expect(input[0].value).toEqual(input[1].value);
expect(container).toMatchSnapshot();
});
test('Renderer:inputDate with minDate & maxDate', async () => {
const {container} = await setup([
{
type: 'input-date',
className: 'test-date-one',
name: 'date',
label: '日期',
valueFormat: 'YY-MM-DD',
minDate: '-1days',
value: '-2days',
embed: true
},
{
type: 'input-date',
className: 'test-date-two',
name: 'date-two',
label: '日期',
valueFormat: 'YY-MM-DD',
maxDate: '+1days',
value: '+2days',
embed: true
}
]);
expect(
container.querySelector('.test-date-one .rdtDay.rdtActive.rdtDisabled')!
).toBeInTheDocument();
expect(
container.querySelector('.test-date-two .rdtDay.rdtActive.rdtDisabled')!
).toBeInTheDocument();
});
test('Renderer:inputDate with shortcuts', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
value: '-1days'
},
{
type: 'static',
name: 'date'
}
]);
const tpl = container.querySelector('.cxd-PlainField')! as HTMLElement;
expect(tpl.innerHTML).toBe(moment().add(-1, 'd').format('YYYY-MM-DD'));
});
test('Renderer:inputDate with shortcuts', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
shortcuts: [
'yesterday',
'thisweek',
'endofthismonth',
'endofthisweek',
'2weekslater'
]
},
{
type: 'static',
name: 'date'
}
]);
const tpl = container.querySelector('.cxd-PlainField')! as HTMLElement;
// 点击打开
const inputDate = container.querySelector('.cxd-DatePicker') as HTMLElement;
fireEvent.click(inputDate);
await wait(300);
const shortcuts = container.querySelectorAll('.cxd-DatePicker-shortcut');
expect(shortcuts.length).toEqual(5);
// 本月末
fireEvent.click(shortcuts[2]);
await waitFor(() => {
expect(tpl.innerHTML).toBe(moment().endOf('M').format('YYYY-MM-DD'));
});
});
test('Renderer:inputDate with clearable', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
value: '2022-08-19'
},
{
type: 'static',
name: 'date'
}
]);
const inputDate = container.querySelector('.cxd-DatePicker') as HTMLElement;
fireEvent.mouseEnter(inputDate);
await waitFor(() => {
expect(
container.querySelector('.cxd-DatePicker .cxd-DatePicker-clear')
).toBeInTheDocument();
});
fireEvent.click(
container.querySelector('.cxd-DatePicker .cxd-DatePicker-clear')!
);
await waitFor(() => {
expect(container.querySelector('.cxd-PlainField')!.innerHTML).toBe(
'<span class="text-muted">-</span>'
);
});
expect(container).toMatchSnapshot('clearable true');
const {container: noClearableCon} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
value: '2022-08-19',
clearable: false
}
]);
fireEvent.mouseEnter(noClearableCon.querySelector('.cxd-DatePicker')!);
await waitFor(() => {
expect(
noClearableCon.querySelector('.cxd-DatePicker .cxd-DatePicker-clear')
).not.toBeInTheDocument();
});
expect(noClearableCon).toMatchSnapshot('clearable false');
});
test('Renderer:inputDate with utc', async () => {
const midnight = moment('2022-08-22 00:00:00').format('YYYY-MM-DD HH:mm:ss');
const utcOneSecondBeforeTomorrow = moment(midnight)
.add(moment().utcOffset(), 'm')
.add(-1, 's')
.format('YYYY-MM-DD HH:mm:ss');
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
value: midnight
},
{
type: 'input-date',
name: 'date-utc',
label: '日期',
valueFormat: 'YYYY-MM-DD',
utc: true,
value: utcOneSecondBeforeTomorrow
}
]);
const inputs = container.querySelectorAll(
'.cxd-DatePicker-input'
)! as unknown as HTMLInputElement[];
expect(inputs[0].value).toBe('2022-08-22');
// 北京时间的 2022-08-22 07:59:59 为 utc 时间的 2022-08-21 23:59:59, 所以为前一天
expect(inputs[1].value).toBe('2022-08-21');
});
test('Renderer:inputDate with closeOnSelect', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
value: '2022-08-22'
}
]);
// 打开弹框
fireEvent.click(container.querySelector('.cxd-DatePicker') as HTMLElement);
// 点击选择
fireEvent.click(
container.querySelector(
'.cxd-DatePicker-popover tr td[data-value="1"]'
) as HTMLElement
);
await wait(500);
// expect(
// container.querySelector('.cxd-PopOver.cxd-DatePicker-popover')
// ).not.toBeInTheDocument();
await waitFor(() => {
expect(
container.querySelector('.cxd-PopOver.cxd-DatePicker-popover')
).not.toBeInTheDocument();
});
const {container: conDontClose} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
value: '2022-08-22',
closeOnSelect: false
}
]);
// 打开弹框
fireEvent.click(conDontClose.querySelector('.cxd-DatePicker') as HTMLElement);
// 点击选择
fireEvent.click(
conDontClose.querySelector(
'.cxd-DatePicker-popover tr td[data-value="1"]'
) as HTMLElement
);
await wait(500);
expect(
conDontClose.querySelector('.cxd-PopOver.cxd-DatePicker-popover')
).toBeInTheDocument();
});
test('Renderer:inputDate disabledDate', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
format: 'YYYY-MM-DD',
disabledDate: 'return currentDate.day() == 1'
}
]);
// 打开弹框
fireEvent.click(container.querySelector('.cxd-DatePicker') as HTMLElement);
const monday = moment().day(1);
const tuesday = moment().day(2);
const todayCell = container.querySelector(
'.cxd-DatePicker-popover td.rdtToday'
)!;
expect(todayCell).toBeInTheDocument();
const toddayTr: HTMLElement = // 因为周日被认为是第一天
// 当今天是周日的时候,moment().day(1) 是明天,moment().day(2) 是后天
// 而日历组件周日是最后一天,所以 moment().day(1) 其实是在下一组里面展示的
(
moment().day() === 0
? todayCell.parentElement?.nextElementSibling
: todayCell.parentElement
) as any;
const mondayCell = toddayTr.querySelector(
'td[data-value="' + monday.date() + '"]'
) as HTMLElement;
const tuesdayCell = toddayTr.querySelector(
'td[data-value="' + tuesday.date() + '"]'
) as HTMLElement;
expect(mondayCell).toHaveClass('rdtDisabled');
expect(tuesdayCell).not.toHaveClass('rdtDisabled');
});
test('Renderer:inputDate defaultValue with formula', async () => {
const {container} = await setup([
{
type: 'input-date',
name: 'date',
label: '日期',
valueFormat: 'YYYY-MM-DD',
value: '${ DATE("2021-12-06 08:20:00") }'
}
]);
await wait(300);
const input = container.querySelector(
'.cxd-DatePicker-input'
)! as HTMLInputElement;
expect(input).toBeInTheDocument();
expect(input.value).toBe('2021-12-06');
});
test('Renderer:inputDate setValue actions with special words', async () => {
const {container, submitBtn, onSubmit, getByText} = await setup([
{
type: 'input-date',
name: 'date',
id: 'date',
label: '日期',
format: 'YYYY-MM-DD'
},
{
type: 'button',
label: '设置值',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'date',
args: {
value: 'today'
}
}
]
}
}
}
]);
// 打开弹框
fireEvent.click(getByText('设置值'));
await wait(200);
const today = moment();
const inputDate = container.querySelector('.cxd-DatePicker-input');
expect(inputDate).toBeInTheDocument();
expect((inputDate as any)?.value).toEqual(today.format('YYYY-MM-DD'));
});

View File

@@ -0,0 +1,92 @@
/**
* 组件名称:InputDateRange 日期
*
*/
import React from 'react';
import PageRenderer from '../../../../amis-core/src/renderers/Form';
import * as renderer from 'react-test-renderer';
import {
render,
fireEvent,
cleanup,
getByText,
waitFor,
screen
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
const setup = async (items: any[] = []) => {
const onSubmit = jest.fn();
const utils = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
submitText: 'Submit',
api: '/api/mock/saveForm?waitSeconds=1',
mode: 'horizontal',
body: items
}
},
{onSubmit},
makeEnv()
)
);
const submitBtn = utils.container.querySelector(
'button[type="submit"]'
) as HTMLElement;
return {
onSubmit,
submitBtn,
...utils
};
};
test('1.Renderer:inputDateRange setValue actions with special words', async () => {
const {container, submitBtn, onSubmit, getByText} = await setup([
{
type: 'input-date-range',
name: 'date',
id: 'date',
label: '日期',
format: 'YYYY-MM-DD'
},
{
type: 'button',
label: '设置值',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'date',
args: {
value: 'today,+2days'
}
}
]
}
}
}
]);
// 打开弹框
fireEvent.click(getByText('设置值'));
await wait(200);
const today = moment();
const inputDates = container.querySelectorAll('.cxd-DateRangePicker-input');
expect(inputDates.length).toBe(2);
expect((inputDates[0] as any)?.value).toEqual(today.format('YYYY-MM-DD'));
expect((inputDates[1] as any)?.value).toEqual(
moment(today).add(2, 'days').format('YYYY-MM-DD')
);
});

View File

@@ -0,0 +1,268 @@
import React = require('react');
import {fireEvent, render, screen} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
test('Renderer:input-formula', async () => {
const {container, findByText, findByDisplayValue} = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
debug: true,
body: [
{
type: 'input-formula',
name: 'formula',
label: '公式',
evalMode: false,
value: 'SUM(1 + 2)',
variables: [
{
label: '表单字段',
children: [
{
label: '文章名',
value: 'name',
tag: '文本'
},
{
label: '作者',
value: 'author',
tag: '文本'
},
{
label: '售价',
value: 'price',
tag: '数字'
},
{
label: '出版时间',
value: 'time',
tag: '时间'
},
{
label: '版本号',
value: 'version',
tag: '数字'
},
{
label: '出版社',
value: 'publisher',
tag: '文本'
}
]
},
{
label: '流程字段',
children: [
{
label: '联系电话',
value: 'telphone'
},
{
label: '地址',
value: 'addr'
}
]
}
]
}
]
}
},
{},
makeEnv({})
)
);
await wait(500);
// await findByDisplayValue('SUM(1 + 2)');
// TODO: 不知道为啥切换到 @swc/jest 后不支持
// expect(container).toMatchSnapshot();
// TODO: 貌似 jsdom 不支持 codemirror,进行不下去了
// const action = document.querySelector('button.cxd-FormulaPicker-action');
// fireEvent.click(action!);
// await findByText('变量');
// const name = await findByText('文章名');
// fireEvent.click(name);
// const confirm = await findByText('确认');
// fireEvent.click(confirm);
// screen.debug();
// const formDebug = JSON.parse(document.querySelector('pre code')!.innerHTML);
// expect(formDebug).toEqual({
// formula: 'nameSUM(1 + 2)'
// });
});
test('Renderer:input-formula button', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
debug: true,
body: [
{
type: 'input-formula',
name: 'formula',
label: '公式',
variableMode: 'tree',
evalMode: false,
value: 'SUM(1 + 2)',
inputMode: 'button',
variables: [
{
label: '表单字段',
children: [
{
label: '文章名',
value: 'name',
tag: '文本'
},
{
label: '作者',
value: 'author',
tag: '文本'
},
{
label: '售价',
value: 'price',
tag: '数字'
},
{
label: '出版时间',
value: 'time',
tag: '时间'
},
{
label: '版本号',
value: 'version',
tag: '数字'
},
{
label: '出版社',
value: 'publisher',
tag: '文本'
}
]
},
{
label: '流程字段',
children: [
{
label: '联系电话',
value: 'telphone'
},
{
label: '地址',
value: 'addr'
}
]
}
]
}
]
}
},
{},
makeEnv({})
)
);
await wait(500);
expect(container).toMatchSnapshot();
});
test('Renderer:input-formula input-group', async () => {
const {container} = render(
amisRender(
{
type: 'page',
body: {
type: 'form',
debug: true,
body: [
{
type: 'input-formula',
name: 'formula',
label: '公式',
variableMode: 'tree',
evalMode: false,
value: 'SUM(1 + 2)',
inputMode: 'input-group',
variables: [
{
label: '表单字段',
children: [
{
label: '文章名',
value: 'name',
tag: '文本'
},
{
label: '作者',
value: 'author',
tag: '文本'
},
{
label: '售价',
value: 'price',
tag: '数字'
},
{
label: '出版时间',
value: 'time',
tag: '时间'
},
{
label: '版本号',
value: 'version',
tag: '数字'
},
{
label: '出版社',
value: 'publisher',
tag: '文本'
}
]
},
{
label: '流程字段',
children: [
{
label: '联系电话',
value: 'telphone'
},
{
label: '地址',
value: 'addr'
}
]
}
]
}
]
}
},
{},
makeEnv({})
)
);
await wait(500);
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,178 @@
/**
* 组件名称: InputGroup 输入组合
* 单测内容:
* 1. 基础使用
* 2. 校验配置
*
*/
import {
render,
cleanup,
fireEvent,
screen,
waitFor
} from '@testing-library/react';
import '../../../src';
import {render as amisRender, clearStoresCache} from '../../../src';
import {makeEnv, wait} from '../../helper';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:InputGroup', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
controls: [
{
type: 'input-group',
name: 'a',
label: 'input-group',
mode: 'horizontal',
className: 'no-border',
horizontal: {
leftFixed: 1,
left: 4,
right: 7
},
controls: [
{
name: 'text',
type: 'text',
validation: 'isUrl',
addOn: {
label: '按钮',
type: 'submit'
}
},
{
name: 'text1',
type: 'text',
hidden: true
}
]
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
const setup = (schema = {}, props = {}, env = {}) => {
const onSubmit = jest.fn();
const submitBtnText = 'Submit';
return render(
amisRender(
{
type: 'form',
api: '/api/mock2/form/saveForm',
submitText: submitBtnText,
body: [
{
type: 'input-group',
name: 'input-group',
label: '输入组合校验',
body: [
{
type: 'input-text',
name: 'child1',
label: 'child1',
validations: {
isNumeric: true,
maxLength: 3
}
},
{
type: 'input-text',
name: 'child2',
validations: {
minLength: 5
}
}
],
...schema
}
]
},
{onSubmit, ...props},
makeEnv({...env})
)
);
};
describe('InputGroup with validationConfig', () => {
test('InputGroup with validationConfig: errorMode', async () => {
const {container} = setup({validationConfig: {errorMode: 'partial'}});
const child1 = container.querySelector(
'input[name=child1]'
) as HTMLInputElement;
const child2 = container.querySelector(
'input[name=child2]'
) as HTMLInputElement;
fireEvent.change(child1, {target: {value: 'amis'}});
await wait(300);
const submitBtn = screen.getByRole('button', {name: 'Submit'});
fireEvent.click(submitBtn);
await wait(500);
expect(
container.querySelector('*[class*="InputGroup-validation--partial"]')
).toBeInTheDocument();
const errorDom = container.querySelector('*[class*="Form-feedback"]');
expect(errorDom?.childElementCount).toStrictEqual(1);
fireEvent.change(child2, {target: {value: 'amis'}});
await wait(300);
fireEvent.click(submitBtn);
await wait(500);
expect(errorDom?.childElementCount).toStrictEqual(2);
});
// v2.9.1 改为顺序校验后,不会同时输出多条校验错误消息,所以也不会用到分隔符
// test('InputGroup with validationConfig: delimiter', async () => {
// const delimiter = '@@';
// const {container} = setup({validationConfig: {delimiter}});
// const child1 = container.querySelector(
// 'input[name=child1]'
// ) as HTMLInputElement;
// const child2 = container.querySelector(
// 'input[name=child2]'
// ) as HTMLInputElement;
// fireEvent.change(child1, {target: {value: 'amis'}});
// await wait(500);
// const submitBtn = screen.getByRole('button', {name: 'Submit'});
// fireEvent.click(submitBtn);
// await wait(500);
// screen.debug(container);
// expect(
// container.querySelector('*[class*="InputGroup-validation--full"]')
// ).toBeInTheDocument();
// const errorDom = container.querySelector('*[class*="Form-feedback"]');
// expect(errorDom?.childElementCount).toStrictEqual(1);
// const child1ErrorText = errorDom?.childNodes[0]
// ? errorDom.childNodes[0].textContent
// : '';
// expect(child1ErrorText).toEqual(expect.stringMatching(delimiter));
// });
});

View File

@@ -0,0 +1,86 @@
import React = require('react');
import PageRenderer from '../../../../amis-core/src/renderers/Form';
import * as renderer from 'react-test-renderer';
import {
render,
fireEvent,
waitFor,
getByText,
prettyDOM
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
test('Renderer:input-image autoFill', async () => {
const fetcher = jest.fn().mockImplementation(() => {
return Promise.resolve({
data: {
status: 0,
msg: 'ok',
data: {
value: 'img.png',
filename: 'filename.png',
myUrl: 'http://amis.com/image.png'
}
}
});
});
global.URL.createObjectURL = jest.fn();
const {
debug,
container,
findByText,
getByLabelText,
findByPlaceholderText,
findByDisplayValue
} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'input-image',
name: 'img',
label: 'img',
receiver: '/api/upload/file',
autoFill: {
// 不知道为啥这里不能用 ${url},可能是有什么地方和真实浏览器不一致
myUrl: '${myUrl}'
}
},
{
type: 'input-text',
name: 'myUrl'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({fetcher})
)
);
const fileInput = container.querySelector(
'input[type=file]'
)! as HTMLInputElement;
const file = new File(['file'], 'ping.png', {
type: 'image/png'
});
fireEvent.change(fileInput, {
target: {files: [file]}
});
await wait(500);
const textInput = container.querySelector(
'input[name=myUrl]'
)! as HTMLInputElement;
expect(textInput.value).toBe('http://amis.com/image.png');
});

View File

@@ -0,0 +1,125 @@
import React from 'react';
import PageRenderer from '../../../../amis-core/src/renderers/Form';
import * as renderer from 'react-test-renderer';
import {
render,
fireEvent,
waitFor,
getByText,
within
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
test('Renderer:inputMonth click', async () => {
const {
debug,
container,
findByText,
findByPlaceholderText,
findByDisplayValue
} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'input-month',
name: 'month',
label: '时间'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const inputDate = await findByPlaceholderText('请选择月份');
fireEvent.click(inputDate);
// 点击前一年
fireEvent.click(
container.querySelector('.cxd-DatePicker-popover .rdtPrev') as Element
);
const firstMonth = await findByText('1月');
fireEvent.click(firstMonth);
const lastYearMonth = moment().subtract(1, 'year').format('YYYY') + '-01';
await findByDisplayValue(lastYearMonth);
const input = container.querySelector(
'.cxd-DatePicker input'
) as HTMLInputElement;
expect(input.value).toEqual(lastYearMonth);
});
test('Renderer:inputMonth with dynamic minDate & maxDate', async () => {
const {container} = render(
amisRender(
{
type: 'form',
body: [
{
label: '开始日期',
type: 'input-month',
name: 'startTime',
size: 'md',
valueFormat: 'YYYY-MM',
maxDate: '${endTime}',
value: '2000-05'
},
{
type: 'input-month',
label: '结束日期',
size: 'md',
name: 'endTime',
valueFormat: 'YYYY-MM',
minDate: '${startTime}',
maxDate: '${startTime} +1year',
value: '2000-10'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const items = container.querySelectorAll('.cxd-DatePicker');
expect(items.length).toBe(2);
const start = items[0];
const end = items[1];
fireEvent.click(end);
await wait(200);
expect(end.querySelector('.rdtMonth:not(.rdtDisabled)')!).toHaveTextContent(
'5月'
);
fireEvent.click(start);
await wait(200);
fireEvent.click(await within(start as HTMLElement).getByText('8月'));
await wait(400);
// 这里两次 click 才能打开 popover
fireEvent.click(end);
fireEvent.click(end);
await wait(400);
expect(end.querySelector('.rdtMonth:not(.rdtDisabled)')!).toHaveTextContent(
'8月'
);
}, 10000);

View File

@@ -0,0 +1,120 @@
/**
* 组件名称:InputMonthRange 月份范围
*
* 备注:InputMonthRange 与 dateRange 等日期范围使用的是同一个组件,所以只测试不同的地方即可
*
* 单测内容:
1. 点击选择
2. timeFormat
*/
import {
render,
fireEvent,
within,
cleanup,
waitFor
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
// 1. 点击选择
test('Renderer:inputMonthRange click', async () => {
const {container, findByPlaceholderText, getByText} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'input-month-range',
name: 'a',
label: '月份范围'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const inputDate = await findByPlaceholderText('开始时间');
fireEvent.click(inputDate);
const thisMonthText = moment().format('M[月]');
const nextMonthText = moment().add(1, 'month').format('M[月]');
const thisMonthValue = moment().format('YYYY-MM');
const nextMonthValue = moment().add(1, 'month').format('YYYY-MM');
const startMonth = await within(
document.querySelector('.cxd-DateRangePicker-start')!
).findByText(thisMonthText);
fireEvent.click(startMonth);
const endMonth = await within(
document.querySelector('.cxd-DateRangePicker-end')!
).findByText(nextMonthText);
fireEvent.click(endMonth);
const confirm = getByText('确认');
fireEvent.click(confirm);
const value = document.querySelectorAll('.cxd-DateRangePicker-input')!;
expect((value[0] as HTMLInputElement).value).toEqual(thisMonthValue);
expect((value[1] as HTMLInputElement).value).toEqual(nextMonthValue);
});
// 2. 内嵌模式
test('Renderer:inputMonthRange with embed', async () => {
const {container, findByPlaceholderText, getByText} = render(
amisRender(
{
type: 'form',
submitText: 'Submit',
api: '/api/xxx',
body: [
{
type: 'input-month-range',
name: 'a',
label: '月份范围',
embed: true,
format: 'YYYY-MM',
value: '2019-10,2022-11'
}
],
title: 'The form'
},
{},
makeEnv({})
)
);
expect(
container.querySelector('.cxd-DateRangePicker-start .rdtSwitch')!.innerHTML
).toBe('2019年');
expect(
container.querySelector(
'.cxd-DateRangePicker-start .rdtMonth.rdtActive span'
)!.innerHTML
).toBe('10月');
expect(
container.querySelector('.cxd-DateRangePicker-end .rdtSwitch')!.innerHTML
).toBe('2022年');
expect(
container.querySelector(
'.cxd-DateRangePicker-end .rdtMonth.rdtActive span'
)!.innerHTML
).toBe('11月');
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,108 @@
/**
* 组件名称:InputQuarterRange 季度范围
*
* 备注:InputQuarterRange 与 dateRange 等日期范围使用的是同一个组件,所以只测试不同的地方即可
*
* 单测内容:
1. 点击选择
2. 内嵌模式
*/
import {
render,
fireEvent,
within,
cleanup,
waitFor
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import moment from 'moment';
// 1. 点击选择
test('Renderer:InputQuarterRange click', async () => {
const {container, findByPlaceholderText, getByText} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'input-quarter-range',
name: 'a',
label: '季度范围'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const inputs = document.querySelectorAll('.cxd-DateRangePicker-input')!;
fireEvent.click(inputs[0]!);
fireEvent.click(
await within(
document.querySelector('.cxd-DateRangePicker-start')!
).findByText('Q1')
);
fireEvent.click(
await within(
document.querySelector('.cxd-DateRangePicker-start')!
).findByText('Q4')
);
fireEvent.click(getByText('确认'));
const thisYear = moment().format('YYYY');
expect((inputs[0] as HTMLInputElement).value).toEqual(`${thisYear}-Q1`);
expect((inputs[1] as HTMLInputElement).value).toEqual(`${thisYear}-Q4`);
});
// 2. 内嵌模式
test('Renderer:InputQuarterRange with embed', async () => {
const onSubmit = jest.fn();
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
submitText: 'Submit',
body: [
{
type: 'input-quarter-range',
name: 'a',
label: '季度范围',
embed: true,
valueFormat: 'YYYY-MM',
displayFormat: 'YYYY/MM',
value: '2021-10,2021-12'
}
]
},
{onSubmit},
makeEnv({})
)
);
expect(
container.querySelector(
'.cxd-DateRangePicker-start .rdtQuarter.rdtActive span'
)!.innerHTML
).toBe('Q4');
expect(
container.querySelector(
'.cxd-DateRangePicker-end .rdtQuarter.rdtActive span'
)!.innerHTML
).toBe('Q4');
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,437 @@
/**
* 组件名称:InputSubForm 子表单
* 单测内容:
* 1. 基础点击勾选
*/
import React from 'react';
import {
render,
cleanup,
screen,
fireEvent,
waitFor
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:InputSubForm base', async () => {
const onChange = jest.fn();
const {getByText, container, baseElement} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-sub-form',
name: 'form',
label: '子Form',
btnLabel: '设置子表单',
onChange,
form: {
title: '配置子表单',
body: [
{
name: 'a',
label: 'A',
type: 'input-text'
},
{
name: 'b',
label: 'B',
type: 'input-text'
}
]
}
}
]
})
);
fireEvent.click(getByText('设置子表单'));
expect(baseElement.querySelector('.cxd-Modal .cxd-Form')).toBeInTheDocument();
const inputs = baseElement.querySelectorAll(
'.cxd-Modal .cxd-Form .cxd-TextControl-input input'
);
expect(inputs!.length).toBe(2);
expect(baseElement).toMatchSnapshot();
fireEvent.change(inputs[0], {
target: {value: 'text-one'}
});
await wait(200);
fireEvent.change(inputs[1], {
target: {value: 'text-two'}
});
await wait(200);
fireEvent.click(getByText('确认'));
await wait(500);
expect(onChange).toBeCalled();
expect(onChange.mock.calls[0][0]).toEqual({
a: 'text-one',
b: 'text-two'
});
});
test('Renderer:InputSubForm with multiple & maxLength & btnLabel', async () => {
const onChange = jest.fn();
const {getByText, container, baseElement} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-sub-form',
name: 'form',
label: '子Form',
btnLabel: '设置${a}',
onChange,
multiple: true,
maxLength: 2,
form: {
title: '配置子表单',
body: [
{
name: 'a',
label: 'A',
type: 'input-text'
},
{
name: 'b',
label: 'B',
type: 'input-text'
}
]
}
}
]
})
);
async function addItem(val1: string, val2: string) {
fireEvent.click(getByText('新增一项'));
const inputs = baseElement.querySelectorAll(
'.cxd-Modal .cxd-Form .cxd-TextControl-input input'
);
fireEvent.change(inputs[0], {
target: {value: val1}
});
await wait(200);
fireEvent.change(inputs[1], {
target: {value: val2}
});
await wait(200);
fireEvent.click(getByText('确认'));
await wait(500);
}
await addItem('val-1-1', 'val-1-2');
expect(onChange).toBeCalled();
expect(onChange.mock.calls[0][0]).toEqual([
{
a: 'val-1-1',
b: 'val-1-2'
}
]);
await addItem('val-2-1', 'val-2-2');
expect(onChange).toBeCalledTimes(2);
expect(onChange.mock.calls[1][0]).toEqual([
{
a: 'val-1-1',
b: 'val-1-2'
},
{
a: 'val-2-1',
b: 'val-2-2'
}
]);
expect(
container.querySelector('.cxd-SubForm-toolbar .cxd-SubForm-addBtn')!
).toHaveAttribute('disabled');
const values = container.querySelectorAll(
'.cxd-SubForm-values .cxd-SubForm-value'
);
expect(values!.length).toBe(2);
expect(values[1]).toHaveTextContent('设置val-2-1');
expect(container).toMatchSnapshot();
});
test('Renderer:InputSubForm with draggable & addable & removable', async () => {
const onChange = jest.fn();
const {getByText, container, baseElement} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-sub-form',
name: 'form',
label: '子Form',
btnLabel: '设置${a}',
onChange,
multiple: true,
draggable: true,
addable: false,
removable: true,
form: {
title: '配置子表单',
body: [
{
name: 'a',
label: 'A',
type: 'input-text'
},
{
name: 'b',
label: 'B',
type: 'input-text'
}
]
},
value: [
{
a: 'val-a'
},
{
a: 'val-b'
},
{
a: 'val-c'
},
{
a: 'val-d'
}
]
}
]
})
);
let values = container.querySelectorAll(
'.cxd-SubForm-values .cxd-SubForm-value'
);
expect(values!.length).toBe(4);
expect(values[1]).toHaveTextContent('设置val-b');
expect(
values[0].querySelector('.cxd-SubForm-valueDragBar')
).toBeInTheDocument();
fireEvent.click(values[0].querySelector('.cxd-SubForm-valueDel')!);
await wait(200);
values = container.querySelectorAll('.cxd-SubForm-values .cxd-SubForm-value');
expect(values!.length).toBe(3);
expect(values[1]).toHaveTextContent('设置val-c');
fireEvent.click(values[0].querySelector('.cxd-SubForm-valueEdit')!);
await wait(200);
expect(baseElement.querySelector('.cxd-Modal .cxd-Form')).toBeInTheDocument();
const firstInput = baseElement.querySelector(
'.cxd-Modal .cxd-Form .cxd-TextControl-input input'
)!;
expect((firstInput as HTMLInputElement)!.value).toBe('val-b');
fireEvent.change(firstInput, {
target: {value: 'val-b-change'}
});
await wait(200);
fireEvent.click(getByText('确认'));
await wait(500);
expect(onChange).toBeCalledTimes(2);
expect(onChange.mock.calls[1][0]).toEqual([
{
a: 'val-b-change'
},
{
a: 'val-c'
},
{
a: 'val-d'
}
]);
expect(container).toMatchSnapshot();
});
test('Renderer:InputSubForm with addButtonClassName & itemsClassName & itemClassName & addButtonText & labelField', async () => {
const {getByText, container, baseElement} = render(
amisRender({
type: 'form',
body: [
{
type: 'input-sub-form',
name: 'form2',
label: '多选',
multiple: true,
labelField: 'title',
itemsClassName: 'items-wrapper',
itemClassName: 'item-classname',
addButtonText: '自定义的新增',
addButtonClassName: 'thisis-add-btn',
value: [
{
title: 'val-a'
},
{
title: 'val-b'
}
],
form: {
title: '配置子表单',
body: [
{
name: 'title',
label: '标题',
required: true,
type: 'input-text'
}
]
}
}
]
})
);
await wait(500);
expect(container).toMatchSnapshot();
expect(container.querySelector('.cxd-SubForm-values')).toHaveClass(
'items-wrapper'
);
expect(
container.querySelector('.cxd-SubForm-values .cxd-SubForm-value')
).toHaveClass('item-classname');
// labelField 这里不知为何不生效
// expect(
// container.querySelector('.cxd-SubForm-values .cxd-SubForm-value')
// ).toHaveTextContent('val-a');
expect(container.querySelector('.cxd-SubForm-addBtn')).toHaveClass(
'thisis-add-btn'
);
expect(container.querySelector('.cxd-SubForm-addBtn')).toHaveTextContent(
'自定义的新增'
);
});
test('Renderer:InputSubForm-can-access-superdata-1', async () => {
const onChange = jest.fn();
const {getByText, container, baseElement} = render(
amisRender({
type: 'form',
data: {
a: '123',
b: '233'
},
body: [
{
type: 'input-sub-form',
name: 'form',
label: '子Form',
btnLabel: '设置子表单',
onChange,
form: {
title: '配置子表单',
body: [
{
name: 'a',
label: 'A',
type: 'input-text'
},
{
name: 'b',
label: 'B',
type: 'input-text'
}
]
}
}
]
})
);
fireEvent.click(getByText('设置子表单'));
expect(baseElement.querySelector('.cxd-Modal .cxd-Form')).toBeInTheDocument();
const inputs = baseElement.querySelectorAll(
'.cxd-Modal .cxd-Form .cxd-TextControl-input input'
);
expect(inputs!.length).toBe(2);
expect((inputs[0] as HTMLInputElement).value).toBe('');
expect((inputs[1] as HTMLInputElement).value).toBe('');
});
test('Renderer:InputSubForm-can-access-superdata-2', async () => {
const onChange = jest.fn();
const {getByText, container, baseElement} = render(
amisRender({
type: 'form',
data: {
a: '123',
b: '233'
},
body: [
{
type: 'input-sub-form',
name: 'form',
label: '子Form',
btnLabel: '设置子表单',
onChange,
form: {
canAccessSuperData: true,
title: '配置子表单',
body: [
{
name: 'a',
label: 'A',
type: 'input-text'
},
{
name: 'b',
label: 'B',
type: 'input-text'
}
]
}
}
]
})
);
fireEvent.click(getByText('设置子表单'));
expect(baseElement.querySelector('.cxd-Modal .cxd-Form')).toBeInTheDocument();
const inputs = baseElement.querySelectorAll(
'.cxd-Modal .cxd-Form .cxd-TextControl-input input'
);
expect(inputs!.length).toBe(2);
expect((inputs[0] as HTMLInputElement).value).toBe('123');
expect((inputs[1] as HTMLInputElement).value).toBe('233');
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,206 @@
import {
render,
screen,
cleanup,
waitFor,
fireEvent
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, replaceReactAriaIds, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
const setupInputTag = async (inputTagOptions: any = {}) => {
const renderResult = render(
amisRender(
{
type: 'form',
wrapWithPanel: false,
body: [
{
type: 'input-tag',
name: 'tag',
label: '标签',
...inputTagOptions
}
]
},
{},
makeEnv({})
)
);
await waitFor(() => {
expect(
renderResult.container.querySelector('input[name="tag"]')
).toBeInTheDocument();
});
const input = renderResult.container.querySelector(
'input[name="tag"]'
) as HTMLInputElement;
return {
...renderResult,
input
};
};
describe('Renderer:InputTag', () => {
test('InputTag with placeholder', async () => {
const placeholder = 'please input the tag';
const {container, input} = await setupInputTag({placeholder});
expect(input.placeholder).toBe(placeholder);
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});
test('InputTag with options', async () => {
const {container, input} = await setupInputTag({
options: ['Apple', 'Orange', 'Banana']
});
fireEvent.focus(input);
await wait(500);
const option = screen.getByText('Apple');
// expect(option).toBeVisible();
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});
test('InputTag input with single tag', async () => {
const {container, input} = await setupInputTag();
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Honey-dew melon'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const option = screen.getByText('Honey-dew melon');
expect(option).toHaveClass('cxd-ResultBox-valueLabel');
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});
test('InputTag input with batch tag', async () => {
const {container, input} = await setupInputTag({enableBatchAdd: true});
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Apple-Orange-Banana'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const Apple = screen.getByText('Apple');
expect(Apple).toHaveClass('cxd-ResultBox-valueLabel');
const Orange = screen.getByText('Orange');
expect(Orange).toHaveClass('cxd-ResultBox-valueLabel');
const Banana = screen.getByText('Banana');
expect(Banana).toHaveClass('cxd-ResultBox-valueLabel');
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});
test('InputTag input with batch tag and separator "|"', async () => {
const {container, input} = await setupInputTag({
enableBatchAdd: true,
separator: '|'
});
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Apple|Orange|Banana'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const Apple = screen.getByText('Apple');
expect(Apple).toHaveClass('cxd-ResultBox-valueLabel');
const Orange = screen.getByText('Orange');
expect(Orange).toHaveClass('cxd-ResultBox-valueLabel');
const Banana = screen.getByText('Banana');
expect(Banana).toHaveClass('cxd-ResultBox-valueLabel');
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
});
test('InputTag input with max quantity 2', async () => {
const {container, input, queryByText} = await setupInputTag({max: 2});
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Apple'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const Apple = screen.getByText('Apple');
expect(Apple).toBeVisible();
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Orange'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const Orange = screen.getByText('Orange');
expect(Orange).toBeVisible();
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Banana'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const Banana = queryByText('Banana');
expect(Banana).toBeNull();
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
}, 10000);
test('InputTag input with maxTagLength 5', async () => {
const {container, input, queryByText} = await setupInputTag({
maxTagLength: 5
});
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Apple'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const Apple = screen.getByText('Apple');
expect(Apple).toBeVisible();
fireEvent.focus(input);
await wait(500);
fireEvent.change(input, {target: {value: 'Banana'}});
await wait(500);
fireEvent.keyDown(input, {key: 'Enter', code: 13});
await wait(500);
const Banana = queryByText('Banana');
expect(Banana).toBeNull();
replaceReactAriaIds(container);
expect(container).toMatchSnapshot();
}, 10000);
});

View File

@@ -0,0 +1,79 @@
import {render, fireEvent, waitFor, screen} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
describe('clearable', () => {
const initSchema = (action = {} as any) => ({
type: 'form',
body: [
{
name: 'text',
type: 'input-text',
placeholder: 'email',
resetValue: '',
clearable: true,
onEvent: {
clear: {
actions: [action]
}
}
}
]
});
test('should execute the clear event handler while clicking the clear icon', async () => {
const mockScript = jest.fn();
const {container} = render(
amisRender(initSchema({actionType: 'custom', script: mockScript}))
);
const inputEl = screen.queryByPlaceholderText('email');
fireEvent.change(inputEl!, {target: {value: 'baidu'}});
expect(screen.queryByDisplayValue('baidu')).toBeInTheDocument();
await waitFor(() => {
const clearEl = container.querySelector('a.cxd-TextControl-clear');
expect(clearEl).toBeInTheDocument();
fireEvent.click(clearEl!);
});
await waitFor(() => {
expect(mockScript).toBeCalledTimes(1);
expect(screen.queryByDisplayValue('baidu')).not.toBeInTheDocument();
});
});
test('should not modify the value of the input if the property preventDefault of the clear event is true', async () => {
const mockScript = jest.fn();
const {container} = render(
amisRender(
initSchema({
actionType: 'custom',
script: mockScript,
preventDefault: true
})
)
);
const inputEl = screen.queryByPlaceholderText('email');
fireEvent.change(inputEl!, {target: {value: 'baidu'}});
expect(screen.queryByDisplayValue('baidu')).toBeInTheDocument();
await waitFor(() => {
const clearEl = container.querySelector('a.cxd-TextControl-clear');
expect(clearEl).toBeInTheDocument();
fireEvent.click(clearEl!);
});
await waitFor(() => {
expect(mockScript).toBeCalledTimes(1);
expect(screen.queryByDisplayValue('baidu')).toBeInTheDocument();
});
});
});

View File

@@ -0,0 +1,46 @@
import React = require('react');
import PageRenderer from '../../../../amis-core/src/renderers/Form';
import * as renderer from 'react-test-renderer';
import {render, fireEvent, cleanup, getByText} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
import moment from 'moment';
test('Renderer:inputYear click', async () => {
const {container, findByPlaceholderText, findByText} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'input-year',
name: 'year',
label: '年'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const inputDate = await findByPlaceholderText('请选择年');
fireEvent.click(inputDate);
const thisYearText = moment().format('YYYY');
const thisYear = await findByText(thisYearText);
fireEvent.click(thisYear);
const value = document.querySelector(
'.cxd-DatePicker input'
) as HTMLInputElement;
expect(value.value).toEqual(thisYearText);
});

View File

@@ -0,0 +1,102 @@
/**
* 组件名称:InputYearRange 年份范围
*
* 备注:InputYearRange 与 dateRange 等日期范围使用的是同一个组件,所以只测试不同的地方即可
*
* 单测内容:
1. 点击选择
2. 内嵌模式
*/
import {render, fireEvent, screen, within} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv} from '../../helper';
import moment from 'moment';
test('Renderer:inputYearRange click', async () => {
const {container, findByPlaceholderText, getByText} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
body: [
{
type: 'input-year-range',
name: 'year',
label: '年'
}
],
title: 'The form',
actions: []
},
{},
makeEnv({})
)
);
const inputDate = await findByPlaceholderText('开始时间');
fireEvent.click(inputDate);
const thisYearText = moment().format('YYYY');
const nextYearText = moment().add(1, 'year').format('YYYY');
const thisYear = await within(
document.querySelector('.cxd-DateRangePicker-start')!
).findByText(thisYearText);
fireEvent.click(thisYear);
const nextYear = await within(
document.querySelector('.cxd-DateRangePicker-end')!
).findByText(nextYearText);
fireEvent.click(nextYear);
const confirm = getByText('确认');
fireEvent.click(confirm);
const value = document.querySelectorAll('.cxd-DateRangePicker-input')!;
expect((value[0] as HTMLInputElement).value).toEqual(thisYearText);
expect((value[1] as HTMLInputElement).value).toEqual(nextYearText);
});
// 2. 内嵌模式
test('Renderer:inputYearRange with embed', async () => {
const {container} = render(
amisRender(
{
type: 'form',
api: '/api/xxx',
submitText: 'Submit',
body: [
{
type: 'input-year-range',
name: 'year',
label: '年',
embed: true,
value: '815155200,3374063999' // 1995 - 2076
}
]
},
{},
makeEnv({})
)
);
expect(
container.querySelector(
'.cxd-DateRangePicker-start .rdtYear.rdtActive span'
)!.innerHTML
).toBe('1995');
expect(
container.querySelector('.cxd-DateRangePicker-end .rdtYear.rdtActive span')!
.innerHTML
).toBe('2076');
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,104 @@
require('react');
import {render, cleanup, fireEvent, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:list', async () => {
const {container} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'list',
name: 'select',
label: '单选',
clearable: true,
options: [
{
label: 'Option A',
value: 'a'
},
{
label: 'Option B',
value: 'b'
},
{
label: 'OptionC',
value: 'c',
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
}
]
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
expect(container).toMatchSnapshot();
});
test('Renderer:list:multiple clearable', async () => {
const {debug, container, findByText} = render(
amisRender(
{
type: 'form',
title: 'The form',
controls: [
{
type: 'list',
name: 'select',
label: '多选',
multiple: true,
clearable: true,
options: [
{
label: 'Option A',
value: 'a'
},
{
label: 'Option B',
value: 'b'
}
]
},
{
type: 'static',
name: 'select',
label: '当前值'
}
],
submitText: null,
actions: []
},
{},
makeEnv()
)
);
// 这个是为了用于监视值是否变更完成
const refDom = container.querySelector('.cxd-PlainField') as Element;
fireEvent.click(await findByText(/Option A/));
await waitFor(() => expect(refDom.innerHTML).toBe('a'));
expect(container).toMatchSnapshot();
fireEvent.click(await findByText(/Option B/));
await waitFor(() => expect(refDom.innerHTML).toBe('a,b'));
expect(container).toMatchSnapshot();
fireEvent.click(await findByText(/Option B/));
await waitFor(() => expect(refDom.innerHTML).toBe('a'));
expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,212 @@
import React from 'react';
import {render, cleanup, fireEvent, waitFor} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
});
test('Renderer:listSelect with multiple & clearable', async () => {
const onSubmit = jest.fn();
const schema = (args?: any) => ({
type: 'form',
submitText: 'Submit',
onSubmit,
body: {
type: 'list-select',
name: 'select',
label: '单选',
// "clearable": true,
// multiple: true,
...args,
options: [
{
label: 'Option A',
value: 'a'
},
{
label: 'Option B',
value: 'b'
}
]
}
});
const {container, rerender, getByText} = render(amisRender(schema()));
const options = container.querySelectorAll('.cxd-ListControl-item');
expect(options!.length).toBe(2);
async function checkRes(times: number, res: any) {
fireEvent.click(getByText('Submit'));
await wait(300);
expect(onSubmit).toBeCalledTimes(times);
expect(onSubmit.mock.calls[times - 1][0]).toEqual(res);
}
fireEvent.click(options[0]!);
await wait(200);
await checkRes(1, {
select: 'a'
});
fireEvent.click(getByText('Option B'));
await wait(200);
await checkRes(2, {
select: 'b'
});
fireEvent.click(getByText('Option B'));
await wait(200);
await checkRes(3, {
select: 'b'
});
rerender(
amisRender(
schema({
clearable: true,
multiple: true
})
)
);
fireEvent.click(getByText('Option B'));
await wait(200);
await checkRes(4, {
select: ''
});
fireEvent.click(getByText('Option B'));
await wait(200);
fireEvent.click(getByText('Option A'));
await wait(200);
await checkRes(5, {
select: 'b,a'
});
expect(container).toMatchSnapshot();
}, 10000);
test('Renderer:listSelect with image option & listClassName', async () => {
const {container, getByText} = render(
amisRender({
type: 'form',
body: {
type: 'list-select',
name: 'select',
label: '单选',
listClassName: 'items-wrapper',
options: [
{
label: 'OptionA',
value: 'a',
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
},
{
label: 'OptionB',
value: 'b',
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
}
]
}
})
);
expect(container).toMatchSnapshot();
const item = container.querySelector('.cxd-ListControl-item');
expect(item).toHaveTextContent('OptionA');
expect(item!.querySelector('.cxd-ListControl-itemImage img')).toHaveAttribute(
'src',
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
);
expect(container.querySelector('.cxd-ListControl-items')).toHaveClass(
'items-wrapper'
);
});
test('Renderer:listSelect with custom list style', async () => {
const {container, getByText} = render(
amisRender({
type: 'form',
body: {
type: 'list-select',
name: 'select',
label: '单选',
listClassName: 'items-wrapper',
value: 'b',
options: [
{
label: 'OptionA',
value: 'a',
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
},
{
label: 'OptionB',
value: 'b',
image:
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
}
],
itemSchema: {
type: 'container',
className: 'item-default',
body: [
{
type: 'tpl',
tpl: '${label}',
inline: true,
wrapperComponent: ''
}
],
style: {
position: 'static',
display: 'block'
},
themeCss: {
baseControlClassName: {
'background:default': '#e06d6d'
}
}
},
activeItemSchema: {
type: 'container',
className: 'item-active',
body: [
{
type: 'tpl',
tpl: '${label}',
inline: true,
wrapperComponent: ''
}
],
style: {
position: 'static',
display: 'block'
},
themeCss: {
baseControlClassName: {
'background:default': '#38f9d4'
}
}
}
}
})
);
expect(container.querySelector('.item-default')).toBeInTheDocument();
expect(container.querySelector('.item-active')).toBeInTheDocument();
});

View File

@@ -0,0 +1,47 @@
import React = require('react');
import {render, fireEvent, screen} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {createMockMediaMatcher, makeEnv, wait} from '../../helper';
import {act} from 'react-dom/test-utils';
let originalMatchMedia: any;
beforeAll(() => {
originalMatchMedia = window.matchMedia;
window.matchMedia = createMockMediaMatcher(true);
});
afterAll(() => {
window.matchMedia = originalMatchMedia;
});
test('Renderer:mobileCity', async () => {
// TODO: 不知道为啥报错了
// const {container, getByText} = render(
// amisRender(
// {
// type: 'form',
// api: '/api/xxx',
// controls: [
// {
// type: 'city',
// name: 'a',
// label: 'city',
// allowDistrict: true,
// allowCity: true
// }
// ],
// title: 'The form',
// actions: []
// },
// {},
// makeEnv({})
// )
// );
// await wait(200);
// fireEvent.click(getByText('请选择操作'));
// fireEvent.click(getByText('确认'));
// screen.debug();
// expect(container).toMatchSnapshot();
});

View File

@@ -0,0 +1,52 @@
import {render, fireEvent} from '@testing-library/react';
import '../../../src';
import moment from 'moment';
import {render as amisRender} from '../../../src';
import {createMockMediaMatcher, makeEnv} from '../../helper';
let originalMatchMedia: any;
beforeAll(() => {
originalMatchMedia = window.matchMedia;
window.matchMedia = createMockMediaMatcher(true);
});
afterAll(() => {
window.matchMedia = originalMatchMedia;
});
test('Renderer:mobile Input Date', async () => {
const {container, findByPlaceholderText, findByText} = render(
amisRender(
{
type: 'form',
api: '/api/mock2/form/saveForm',
body: [
{
type: 'input-date',
name: 'date',
label: '日期'
}
]
},
{},
makeEnv({})
)
);
const inputDate = await findByPlaceholderText('请选择日期');
fireEvent.click(inputDate);
// mobile判断有问题
// const confirmButton = document.querySelector(
// '.cxd-PickerColumns-confirm'
// ) as HTMLButtonElement;
// fireEvent.click(confirmButton);
// const value = document.querySelector(
// '.cxd-DatePicker-value'
// ) as HTMLSpanElement;
// TODO: 这里原组件的日错了,等修复
// expect(value.innerHTML).toEqual(moment().format('YYYY-MM-DD'));
});

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