mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
Merge pull request #4969 from tooeast/feat-unit-test-721
chore: 补充 radios, switch, input-text 单测
This commit is contained in:
commit
c4b5ba7533
@ -243,8 +243,8 @@ api 返回内容需要包含 options 字段
|
||||
| ------------ | ----------------------------------------- | --------- | ------------------------------------------------------------------------------------------- |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./options#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| labelField | `boolean` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `boolean` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| labelField | `string` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `string` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| columnsCount | `number` | `1` | 选项按几列显示,默认为一列 |
|
||||
| inline | `boolean` | `true` | 是否显示为一行 |
|
||||
| selectFirst | `boolean` | `false` | 是否默认选中第一个 |
|
||||
|
@ -359,6 +359,198 @@ exports[`Renderer:radios 2`] = `
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:radios source & autoFill 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="cxd-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="cxd-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<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"
|
||||
>
|
||||
<label
|
||||
class="cxd-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<span>
|
||||
radios
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="cxd-RadiosControl cxd-Form-control"
|
||||
>
|
||||
<div
|
||||
class="cxd-Grid"
|
||||
>
|
||||
<div
|
||||
class="cxd-Grid-col--sm4"
|
||||
>
|
||||
<label
|
||||
class="cxd-Checkbox cxd-Checkbox--radio cxd-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="class-a"
|
||||
>
|
||||
A
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Grid-col--sm4"
|
||||
>
|
||||
<label
|
||||
class="cxd-Checkbox cxd-Checkbox--radio cxd-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="class-a"
|
||||
>
|
||||
B
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Grid-col--sm4"
|
||||
>
|
||||
<label
|
||||
class="cxd-Checkbox cxd-Checkbox--radio cxd-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="class-a"
|
||||
>
|
||||
C
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Form-item cxd-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="cxd-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<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 autoFillClass"
|
||||
>
|
||||
<span>
|
||||
13
|
||||
</span>
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
|
@ -62,7 +62,9 @@ exports[`Renderer:Switch Switch basic props 1`] = `
|
||||
/>
|
||||
<span
|
||||
class="text"
|
||||
/>
|
||||
>
|
||||
已开启飞行模式
|
||||
</span>
|
||||
<span
|
||||
class="slider"
|
||||
/>
|
||||
|
@ -391,7 +391,135 @@ exports[`Renderer:text type is email: validate success 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text type is password 1`] = `
|
||||
exports[`Renderer:text type is password with revealPassword 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="cxd-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="cxd-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<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-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="cxd-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<span>
|
||||
text
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="cxd-Form-control cxd-TextControl"
|
||||
>
|
||||
<div
|
||||
class="cxd-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
class=""
|
||||
name="text"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="password"
|
||||
value="abcd"
|
||||
/>
|
||||
</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"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
提交
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text type is password: password invisible 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
@ -527,6 +655,142 @@ exports[`Renderer:text type is password 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text type is password: password visible 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="cxd-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="cxd-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<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-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="cxd-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<span>
|
||||
text
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="cxd-Form-control cxd-TextControl"
|
||||
>
|
||||
<div
|
||||
class="cxd-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="cxd-TextControl-input-password"
|
||||
name="text"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="abcd"
|
||||
/>
|
||||
<a
|
||||
class="cxd-TextControl-revealPassword"
|
||||
>
|
||||
<icon-mock
|
||||
classname="icon icon-view"
|
||||
icon="view"
|
||||
/>
|
||||
</a>
|
||||
</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"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
提交
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text type is url: validate fail 1`] = `
|
||||
<div>
|
||||
<div
|
||||
@ -1598,6 +1862,141 @@ exports[`Renderer:text with counter and maxLength 2`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text with minLength 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="cxd-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="cxd-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<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 is-error has-error--maxLength"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="cxd-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<span>
|
||||
text
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="cxd-Form-control is-error has-error--maxLength cxd-TextControl"
|
||||
>
|
||||
<div
|
||||
class="cxd-TextControl-input cxd-TextControl-input--borderHalf test-text-class-one"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="test-text-class-two"
|
||||
name="text"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="123456789"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<ul
|
||||
class="cxd-Form-feedback"
|
||||
>
|
||||
<li>
|
||||
请控制内容长度, 不要输入 8 个以上字符
|
||||
</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"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
提交
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text with options 1`] = `
|
||||
<div>
|
||||
<div
|
||||
@ -1739,7 +2138,7 @@ exports[`Renderer:text with options 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text with options and multiple: first option selected 1`] = `
|
||||
exports[`Renderer:text with options and multiple and delimiter: first option selected 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
@ -1870,6 +2269,24 @@ exports[`Renderer:text with options and multiple: first option selected 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Form-item cxd-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-static"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-control"
|
||||
>
|
||||
<span
|
||||
class="cxd-PlainField"
|
||||
>
|
||||
a
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div
|
||||
@ -1931,7 +2348,7 @@ exports[`Renderer:text with options and multiple: first option selected 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text with options and multiple: options is opened 1`] = `
|
||||
exports[`Renderer:text with options and multiple and delimiter: options is opened 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
@ -2057,6 +2474,28 @@ exports[`Renderer:text with options and multiple: options is opened 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Form-item cxd-Form-item--normal"
|
||||
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
|
||||
@ -2118,7 +2557,7 @@ exports[`Renderer:text with options and multiple: options is opened 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text with options and multiple: options is opened again, and first option already selected 1`] = `
|
||||
exports[`Renderer:text with options and multiple and delimiter: options is opened again, and first option already selected 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
@ -2249,6 +2688,24 @@ exports[`Renderer:text with options and multiple: options is opened again, and f
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Form-item cxd-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-static"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-control"
|
||||
>
|
||||
<span
|
||||
class="cxd-PlainField"
|
||||
>
|
||||
a
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div
|
||||
@ -2310,7 +2767,7 @@ exports[`Renderer:text with options and multiple: options is opened again, and f
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text with options and multiple: second option selected 1`] = `
|
||||
exports[`Renderer:text with options and multiple and delimiter: second option selected 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
@ -2347,7 +2804,7 @@ exports[`Renderer:text with options and multiple: second option selected 1`] = `
|
||||
class="cxd-Form--debug"
|
||||
>
|
||||
{
|
||||
"text": "a,b"
|
||||
"text": "a-b"
|
||||
}
|
||||
</code>
|
||||
</pre>
|
||||
@ -2444,6 +2901,224 @@ exports[`Renderer:text with options and multiple: second option selected 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Form-item cxd-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-static"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-control"
|
||||
>
|
||||
<span
|
||||
class="cxd-PlainField"
|
||||
>
|
||||
a-b
|
||||
</span>
|
||||
</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"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
提交
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Renderer:text with options and multiple and delimiter: thrid option create 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="cxd-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="cxd-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<span>
|
||||
表单
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Panel-body"
|
||||
>
|
||||
<form
|
||||
class="cxd-Form cxd-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
<pre>
|
||||
<code
|
||||
class="cxd-Form--debug"
|
||||
>
|
||||
{
|
||||
"text": "a-b-AbCd"
|
||||
}
|
||||
</code>
|
||||
</pre>
|
||||
<div
|
||||
class="cxd-Form-item cxd-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="cxd-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="cxd-TplField"
|
||||
>
|
||||
<span>
|
||||
text
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="cxd-Form-control cxd-TextControl is-focused"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="listbox"
|
||||
aria-labelledby="downshift-1-label"
|
||||
class="cxd-TextControl-input cxd-TextControl-input--withAC cxd-TextControl-input--multiple"
|
||||
role="combobox"
|
||||
>
|
||||
<div
|
||||
class="cxd-TextControl-value"
|
||||
>
|
||||
<span
|
||||
class="cxd-TextControl-valueLabel"
|
||||
>
|
||||
OptionA
|
||||
</span>
|
||||
<icon-mock
|
||||
classname="cxd-TextControl-valueIcon icon icon-close"
|
||||
icon="close"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-TextControl-value"
|
||||
>
|
||||
<span
|
||||
class="cxd-TextControl-valueLabel"
|
||||
>
|
||||
OptionB
|
||||
</span>
|
||||
<icon-mock
|
||||
classname="cxd-TextControl-valueIcon icon icon-close"
|
||||
icon="close"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-TextControl-value"
|
||||
>
|
||||
<span
|
||||
class="cxd-TextControl-valueLabel"
|
||||
>
|
||||
AbCd
|
||||
</span>
|
||||
<icon-mock
|
||||
classname="cxd-TextControl-valueIcon icon icon-close"
|
||||
icon="close"
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
aria-autocomplete="list"
|
||||
aria-labelledby="downshift-1-label"
|
||||
autocomplete="off"
|
||||
class=""
|
||||
id="downshift-1-input"
|
||||
name="text"
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="cxd-Form-item cxd-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-static"
|
||||
>
|
||||
<div
|
||||
class="cxd-Form-control"
|
||||
>
|
||||
<span
|
||||
class="cxd-PlainField"
|
||||
>
|
||||
a-b-AbCd
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div
|
||||
|
@ -64,3 +64,80 @@ test('Renderer:radios', async () => {
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
test('Renderer:radios source & autoFill', async () => {
|
||||
const {getByText, container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
name: 'A',
|
||||
id: 'aa',
|
||||
fill: '11'
|
||||
},
|
||||
{
|
||||
name: 'B',
|
||||
id: 'bb',
|
||||
fill: '12'
|
||||
},
|
||||
{
|
||||
name: 'C',
|
||||
id: 'cc',
|
||||
fill: '13'
|
||||
}
|
||||
]
|
||||
},
|
||||
body: [
|
||||
{
|
||||
name: 'radios',
|
||||
type: 'radios',
|
||||
label: 'radios',
|
||||
inline: false,
|
||||
columnsCount: 3,
|
||||
selectFirst: true,
|
||||
source: '${items}',
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
optionClassName: 'class-a',
|
||||
autoFill: {
|
||||
fillFromRadios: "${fill}"
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'radios',
|
||||
label: '当前值'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
className: 'autoFillClass',
|
||||
tpl: '${fillFromRadios}'
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
(container.querySelector('.cxd-PlainField') as Element).innerHTML
|
||||
).toBe('aa');
|
||||
});
|
||||
|
||||
fireEvent.click(getByText(/C/));
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
(container.querySelector('.cxd-TplField.autoFillClass span') as Element).innerHTML
|
||||
).toBe('13');
|
||||
});
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import {render, cleanup, waitFor} from '@testing-library/react';
|
||||
import '../../../src';
|
||||
import {render as amisRender} from '../../../src';
|
||||
import {makeEnv} from '../../helper';
|
||||
@ -26,7 +26,9 @@ describe('Renderer:Switch', () => {
|
||||
falseValue: false,
|
||||
disabled: false,
|
||||
option: 'switch',
|
||||
optionAtLeft: false
|
||||
optionAtLeft: false,
|
||||
onText: "已开启飞行模式",
|
||||
offText: "已关闭飞行模式"
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
@ -36,6 +38,11 @@ describe('Renderer:Switch', () => {
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
expect(
|
||||
(container.querySelector('.cxd-SwitchControl .cxd-Switch .text') as Element).innerHTML
|
||||
).toBe('已开启飞行模式');
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
@ -10,7 +10,7 @@ afterEach(() => {
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
const setup = async (inputOptions: any = {}, formOptions: any = {}) => {
|
||||
const setup = async (inputOptions: any = {}, formOptions: any = {}, formItems: any[] = [{}]) => {
|
||||
const utils = render(
|
||||
amisRender(
|
||||
{
|
||||
@ -23,7 +23,8 @@ const setup = async (inputOptions: any = {}, formOptions: any = {}) => {
|
||||
type: 'input-text',
|
||||
changeImmediately: true,
|
||||
...inputOptions
|
||||
}
|
||||
},
|
||||
...formItems
|
||||
],
|
||||
...formOptions
|
||||
},
|
||||
@ -115,6 +116,41 @@ test('Renderer:text type is password', async () => {
|
||||
type: 'input-password'
|
||||
});
|
||||
|
||||
fireEvent.change(input, {target: {value: 'abcd'}});
|
||||
await wait(300);
|
||||
|
||||
expect(
|
||||
input.getAttribute('type')
|
||||
).toBe('password');
|
||||
expect(container).toMatchSnapshot('password invisible');
|
||||
|
||||
const revealPasswordBtn = container.querySelector(
|
||||
'.cxd-TextControl-revealPassword'
|
||||
) as HTMLElement;
|
||||
|
||||
fireEvent.click(revealPasswordBtn);
|
||||
|
||||
await wait(300);
|
||||
|
||||
expect(
|
||||
input.getAttribute('type')
|
||||
).toBe('text');
|
||||
expect(container).toMatchSnapshot('password visible');
|
||||
});
|
||||
|
||||
/**
|
||||
* type 为 password revealPassword
|
||||
*/
|
||||
test('Renderer:text type is password with revealPassword', async () => {
|
||||
const {container, input} = await setup({
|
||||
type: 'input-password',
|
||||
revealPassword: false
|
||||
});
|
||||
|
||||
expect(
|
||||
container.querySelector('.cxd-TextControl-revealPassword') as Element
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.change(input, {target: {value: 'abcd'}});
|
||||
await wait(300);
|
||||
expect(container).toMatchSnapshot();
|
||||
@ -192,9 +228,9 @@ test('Renderer:text with options', async () => {
|
||||
});
|
||||
|
||||
/**
|
||||
* 选择器模式,多选
|
||||
* 选择器模式,多选、分隔符、提取值
|
||||
*/
|
||||
test('Renderer:text with options and multiple', async () => {
|
||||
test('Renderer:text with options and multiple and delimiter', async () => {
|
||||
const {container, input} = await setup(
|
||||
{
|
||||
multiple: true,
|
||||
@ -215,9 +251,20 @@ test('Renderer:text with options and multiple', async () => {
|
||||
label: 'OptionD',
|
||||
value: 'd'
|
||||
}
|
||||
]
|
||||
],
|
||||
delimiter: '-',
|
||||
joinValues: true,
|
||||
creatable: true
|
||||
},
|
||||
{debug: true}
|
||||
{
|
||||
debug: true
|
||||
},
|
||||
[
|
||||
{
|
||||
type: 'static',
|
||||
name: 'text'
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
const textControl = container.querySelector(
|
||||
@ -253,8 +300,27 @@ test('Renderer:text with options and multiple', async () => {
|
||||
) as HTMLElement
|
||||
);
|
||||
await wait(300);
|
||||
// expect(input.value).toBe('a,b');
|
||||
|
||||
// 分隔符
|
||||
expect(
|
||||
(container.querySelector('.cxd-PlainField') as Element).innerHTML
|
||||
).toBe('a-b');
|
||||
|
||||
expect(container).toMatchSnapshot('second option selected');
|
||||
|
||||
// 可创建
|
||||
fireEvent.click(textControl);
|
||||
await wait(300);
|
||||
fireEvent.change(input, {target: {value: 'AbCd'}});
|
||||
await wait(500);
|
||||
fireEvent.keyDown(input, {key: 'Enter', code: 13});
|
||||
await wait(500);
|
||||
|
||||
expect(
|
||||
(container.querySelector('.cxd-PlainField') as Element).innerHTML
|
||||
).toBe('a-b-AbCd');
|
||||
|
||||
expect(container).toMatchSnapshot('thrid option create');
|
||||
});
|
||||
|
||||
/**
|
||||
@ -324,3 +390,83 @@ test('Renderer:text with transform upperCase', async () => {
|
||||
await wait(300);
|
||||
expect(input.value).toBe('ABCD');
|
||||
});
|
||||
|
||||
/**
|
||||
* 配置 resetValue and trimContents
|
||||
*/
|
||||
test('Renderer:text with resetValue and trimContents', async () => {
|
||||
const {container, input, submitBtn} = await setup({
|
||||
resetValue: 'reset-value',
|
||||
value: 'text-value',
|
||||
trimContents: true
|
||||
}, {}, [
|
||||
{
|
||||
type: 'action',
|
||||
actionType: 'reset',
|
||||
target: 'text',
|
||||
className: 'reset-button'
|
||||
}
|
||||
]);
|
||||
|
||||
fireEvent.click(
|
||||
container.querySelector('.cxd-Button.reset-button')
|
||||
);
|
||||
|
||||
await wait(500);
|
||||
|
||||
expect(input.value).toBe('reset-value');
|
||||
|
||||
// trimContents
|
||||
const textControl = container.querySelector(
|
||||
'.cxd-TextControl-input'
|
||||
) as HTMLElement;
|
||||
|
||||
fireEvent.click(textControl);
|
||||
await wait(300);
|
||||
fireEvent.change(input, {target: {value: ' abcde '}});
|
||||
await wait(500);
|
||||
fireEvent.blur(input);
|
||||
await wait(500);
|
||||
|
||||
expect(input.value).toBe('abcde');
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 配置 minLength、borderMode and className
|
||||
*/
|
||||
test('Renderer:text with minLength', async () => {
|
||||
const {container, input, submitBtn} = await setup({
|
||||
minLength: 5,
|
||||
maxLength: 8,
|
||||
borderMode: 'half',
|
||||
inputControlClassName: 'test-text-class-one',
|
||||
nativeInputClassName: 'test-text-class-two'
|
||||
}, {});
|
||||
|
||||
const textControl = container.querySelector(
|
||||
'.cxd-TextControl-input'
|
||||
) as HTMLElement;
|
||||
|
||||
// 测试 minLength
|
||||
fireEvent.click(textControl);
|
||||
await wait(300);
|
||||
fireEvent.change(input, {target: {value: '1234'}});
|
||||
await wait(500);
|
||||
fireEvent.click(submitBtn);
|
||||
await wait(300);
|
||||
expect(
|
||||
container.querySelector('.cxd-TextControl.has-error--minLength') as Element
|
||||
).toBeInTheDocument();
|
||||
|
||||
// 测试 maxLength
|
||||
fireEvent.click(textControl);
|
||||
await wait(300);
|
||||
fireEvent.change(input, {target: {value: '123456789'}});
|
||||
await wait(500);
|
||||
expect(
|
||||
container.querySelector('.cxd-TextControl.has-error--maxLength') as Element
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
Loading…
Reference in New Issue
Block a user