mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:38:53 +08:00
5520004dec
* feat: select transfer 除树形模式外,增加虚拟列表能力 (#5612) * feat: select transfer 除树形模式外,增加虚拟列表能力 * 修改分组模式问题 * 更新快照 * transfer 虚拟列表单测补充 * select 虚拟列表单测补充 * 更新 select 快照 * chore: merge master into feat-virtual-list branch (#5716) * chore: combo组件items扩充编辑器的拖拽点位 (#5693) * feat: combo组件items支持编辑器的拖拽 * feat: combo组件items支持编辑器的拖拽 * feat: combo组件items支持编辑器的拖拽 * feat: combo组件items支持编辑器的拖拽 * fix: 数字输入框-属性配置-placeholder置灰+边框与form-input统一 amis-saas-4938 (#5666) Co-authored-by: limengyang03 <limengyang03@baidu.com> * feat:Remark组件支持自定义图标 (#5694) * feat:Remark组件支持自定义图标 * 去掉多余内容 Co-authored-by: xujiahao01 <xujiahao01@baidu.com> * fix: 修复 amis本地跑不起来 问题 * fix: https://github.com/baidu/amis/issues/4681 * feat: 使用cross-env 设置NODE_ENV 变量 * perf: 删除重复声明项 * revert: 恢复删除的SchemaRedirect Co-authored-by: 吴多益 <wuduoyi@baidu.com> * feat: ui 组件 form 支持 autoSubmit (#5695) * feat: ui 组件 form 支持 autoSubmit * 下发 onSubmit 否则只能用 handleSubmit 这个会绕过 form 的检测,无法通知到上层 * chore: sdk embed 方法添加 callback 在 callback 中可确保 scoped 方法是可用的 (#5698) * publish beta * chore: sdk embed 方法添加 callback 在 callback 中可确保 scoped 方法是可用的 * fix: filter 过滤器 isTrue/isFalse 问题修复 (#5676) * fix: filter 过滤器 isTrue 问题修复 * 修改 * 修改 * 修改 * chore: InputArray新增默认值示例, 调整Combo组件scaffold逻辑 (#5701) * chore: InputNumber严格判断大数模式,避免错误抛出string类型值 (#5703) * fix: 修复查看代码报 require is not defined 错误 (#5704) * publish beta * fix: 修复查看代码报 require is not defined 错误 * feat: 补充 ConfirmBox ui 控件, 并将 PickerContainer 改成 ConfirmBox 实现 (#5708) * publish beta * feat: 添加 ui ConfirmBox * feat: 补充 confirmBox ui 控件, 并将 pickerContainer 改成 confirmBox 实现 * PickerContainer title 逻辑不变动 * 暴露 InputTableColumnProps * 调整 ts 定义 * 升级 react-hook-form * inputTable 补充数组本身的验证 * Combo 也支持内部数组的验证 * 调整内部验证 * 调整目录 * chore: 优化 locale, theme hoc, 存在 context 直接复用 (#5702) * publish beta * chore: 优化 locale, theme hoc, 存在 context 直接复用 * chore: 日期范围类组件单元测试补充 (#5705) * dateRange * datetimeRange * timeRange * monthRange * quarter and year * 修改 * 修改 * fix: 评分组件 count 支持变量获取 (#5681) * fix: 评分组件 count 支持变量获取 * tokenize 修改为 filter Co-authored-by: zhou999 <zhousq809@163.com> Co-authored-by: PE_Sicca <46698676+swjtulmy@users.noreply.github.com> Co-authored-by: limengyang03 <limengyang03@baidu.com> Co-authored-by: 徐佳豪 <1440054388@qq.com> Co-authored-by: xujiahao01 <xujiahao01@baidu.com> Co-authored-by: h7ml <h7ml@qq.com> Co-authored-by: 吴多益 <wuduoyi@baidu.com> Co-authored-by: liaoxuezhi <2betop.cn@gmail.com> Co-authored-by: sansiro <sansiro@sansiro.me> * feat: tree 增加虚拟列表 (#5696) * feat: Tree 使用 VirtualList 渲染, 提升大数据时的性能 * fix: 适配编辑和新建 * chore: 增加 Tree 测试用例 * chore: 更新 Tree 测试用例 * feat: Tree虚拟列表,调整props名称 * chore: 清理 Tree 相关的无用代码 * feat: select transfer 树形模式增加虚拟滚动支持, treeSelect 虚拟滚动参数 (#5799) * 其他 transfer 支持虚拟列表属性 * feat: select transfer 树形模式增加虚拟滚动支持, treeSelect 虚拟滚动参数 * add * fix: tree 多级时,通过递归parent来判断展开收起,递归partial判断父元素的Partial状态 (#5807) * fix: 调整 tree 组件中,判断父子关系的方法 (#5814) * Revert "chore: merge master into feat-virtual-list branch (#5716)" (#5825) This reverts commit c9895812989c31d3471d50c2adaf7110478ad0a0. * chore: 更新 tree 虚拟滚动相关快照 和一些优化 Co-authored-by: RUNZE LU <36724300+lurunze1226@users.noreply.github.com> Co-authored-by: zhou999 <zhousq809@163.com> Co-authored-by: PE_Sicca <46698676+swjtulmy@users.noreply.github.com> Co-authored-by: limengyang03 <limengyang03@baidu.com> Co-authored-by: 徐佳豪 <1440054388@qq.com> Co-authored-by: xujiahao01 <xujiahao01@baidu.com> Co-authored-by: h7ml <h7ml@qq.com> Co-authored-by: 吴多益 <wuduoyi@baidu.com> Co-authored-by: liaoxuezhi <2betop.cn@gmail.com> Co-authored-by: meerkat <kit_hack@outlook.com>
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
import {waitFor} from '@testing-library/react';
|
|
import {RenderOptions} from '../src';
|
|
|
|
// jest.useFakeTimers 会修改 global 的 setTimeout 所以需要把原始的记录下来。
|
|
const timerFn = (global as any).originSetTimeout || setTimeout;
|
|
export function wait(duration: number, fnOrUseWaitFor?: Function | boolean) {
|
|
const useWaitFor = fnOrUseWaitFor !== false;
|
|
const fn = (
|
|
typeof fnOrUseWaitFor === 'function' ? fnOrUseWaitFor : undefined
|
|
) as Function;
|
|
|
|
return useWaitFor
|
|
? waitFor(
|
|
() =>
|
|
new Promise<void>(resolve => {
|
|
timerFn(() => {
|
|
fn && fn();
|
|
resolve();
|
|
}, duration);
|
|
}),
|
|
{
|
|
timeout: duration + 100
|
|
}
|
|
)
|
|
: new Promise<void>(resolve => {
|
|
timerFn(() => {
|
|
fn && fn();
|
|
resolve();
|
|
}, duration);
|
|
});
|
|
}
|
|
|
|
export function makeEnv(env?: Partial<RenderOptions>): RenderOptions {
|
|
return {
|
|
session: 'test-case',
|
|
isCancel: () => false,
|
|
notify: (msg: string) => null,
|
|
jumpTo: (to: string) => console.info('Now should jump to ' + to),
|
|
alert: msg => console.info(`Alert: ${msg}`),
|
|
...env
|
|
};
|
|
}
|
|
|
|
export const createMockMediaMatcher =
|
|
(matchesOrMapOfMatches: any) => (qs: any) => ({
|
|
matches:
|
|
typeof matchesOrMapOfMatches === 'object'
|
|
? matchesOrMapOfMatches[qs]
|
|
: matchesOrMapOfMatches,
|
|
media: '',
|
|
addListener: () => {},
|
|
addEventListener: () => {},
|
|
removeEventListener: () => {},
|
|
onchange: () => {},
|
|
removeListener: () => {},
|
|
dispatchEvent: () => {
|
|
return true;
|
|
}
|
|
});
|
|
|
|
export function formatStyleObject(style: string | null, px2number = true) {
|
|
if (!style) {
|
|
return {};
|
|
}
|
|
|
|
// 去除注释 /* xx */
|
|
style = style.replace(/\/\*[^(\*\/)]*\*\//g, '');
|
|
|
|
const res: any = {};
|
|
style.split(';').forEach((item: string) => {
|
|
if (!item || !String(item).includes(':')) return;
|
|
|
|
const [key, value] = item.split(':');
|
|
|
|
res[String(key).trim()] =
|
|
px2number && value.endsWith('px')
|
|
? Number(String(value).replace(/px$/, ''))
|
|
: String(value).trim();
|
|
});
|
|
|
|
return res;
|
|
}
|