diff --git a/__mocks__/svgMock.js b/__mocks__/svgMock.js new file mode 100644 index 00000000..57dc8ed7 --- /dev/null +++ b/__mocks__/svgMock.js @@ -0,0 +1,5 @@ +const React = require('react'); + +module.exports = React.forwardRef((props, ref) => + React.createElement('icon-mock', {ref, ...props}) +); diff --git a/__tests__/__snapshots__/factory.test.tsx.snap b/__tests__/__snapshots__/factory.test.tsx.snap index 536bd0b7..dc9354cf 100644 --- a/__tests__/__snapshots__/factory.test.tsx.snap +++ b/__tests__/__snapshots__/factory.test.tsx.snap @@ -128,6 +128,7 @@ exports[`factory:definitions 1`] = ` autocomplete="off" name="ref1" placeholder="" + size="10" type="text" value="ref value" /> @@ -190,6 +191,7 @@ exports[`factory:definitions 1`] = ` autocomplete="off" name="key" placeholder="" + size="10" type="text" value="" /> @@ -216,6 +218,7 @@ exports[`factory:definitions 1`] = ` autocomplete="off" name="value" placeholder="" + size="10" type="text" value="ref value" /> @@ -239,33 +242,6 @@ exports[`factory:definitions 1`] = ` children -
\\$ref
引入的组件'
+ },
+ bb: {
+ type: 'combo',
+ multiple: true,
+ multiLine: true,
+ remark: 'combo
中的子项引入自身,实现嵌套的效果',
+ controls: [
+ {
+ label: 'combo 1',
type: 'text',
- name: 'jack',
- value: 'ref value',
- remark: '通过\\$ref
引入的组件'
- },
- bb: {
- type: 'combo',
- multiple: true,
- multiLine: true,
- remark: 'combo
中的子项引入自身,实现嵌套的效果',
- controls: [
- {
- label: 'combo 1',
- type: 'text',
- name: 'key'
- },
- {
- label: 'combo 2',
- name: 'value',
- $ref: 'aa'
- },
- {
- name: 'children',
- label: 'children',
- $ref: 'bb'
- }
- ]
- }
+ name: 'key'
+ },
+ {
+ label: 'combo 2',
+ name: 'value',
+ $ref: 'aa'
+ },
+ {
+ name: 'children',
+ label: 'children',
+ $ref: 'bb'
+ }
+ ]
+ }
},
type: 'page',
title: '引用',
body: [
- {
- type: 'form',
- api: 'api/xxx',
- actions: [],
- controls: [
- {
- label: 'text2',
- $ref: 'aa',
- name: 'ref1'
- },
- {
- label: 'combo',
- $ref: 'bb',
- name: 'ref2'
- }
- ]
- }
+ {
+ type: 'form',
+ api: 'api/xxx',
+ actions: [],
+ controls: [
+ {
+ label: 'text2',
+ $ref: 'aa',
+ name: 'ref1'
+ },
+ {
+ label: 'combo',
+ $ref: 'bb',
+ name: 'ref2'
+ }
+ ]
+ }
]
- }, {
- }, makeEnv({
- })));
+ },
+ {},
+ makeEnv({})
+ )
+ );
- fireEvent.click(getByText('新增'));
- expect(container).toMatchSnapshot();
+ await wait(100);
+ fireEvent.click(getByText('新增'));
+ expect(container).toMatchSnapshot();
});
test('factory:definitions override', () => {
- const {
- container
- } = render(amisRender({
+ const {container} = render(
+ amisRender(
+ {
definitions: {
- aa: {
+ aa: {
+ type: 'text',
+ name: 'jack',
+ remark: '通过\\$ref
引入的组件'
+ },
+ bb: {
+ type: 'combo',
+ multiple: true,
+ multiLine: true,
+ remark: 'combo
中的子项引入自身,实现嵌套的效果',
+ controls: [
+ {
+ label: 'combo 1',
type: 'text',
- name: 'jack',
- remark: '通过\\$ref
引入的组件'
- },
- bb: {
- type: 'combo',
- multiple: true,
- multiLine: true,
- remark: 'combo
中的子项引入自身,实现嵌套的效果',
- controls: [
- {
- label: 'combo 1',
- type: 'text',
- name: 'key'
- },
- {
- label: 'combo 2',
- name: 'value',
- $ref: 'aa'
- },
- {
- name: 'children',
- label: 'children',
- $ref: 'bb'
- }
- ]
- }
+ name: 'key'
+ },
+ {
+ label: 'combo 2',
+ name: 'value',
+ $ref: 'aa'
+ },
+ {
+ name: 'children',
+ label: 'children',
+ $ref: 'bb'
+ }
+ ]
+ }
},
type: 'page',
title: '引用',
body: [
- {
- type: 'form',
- api: 'api/xxx',
- actions: [],
- controls: [
- {
- label: 'text2',
- $ref: 'aa',
- name: 'ref1'
- },
- {
- label: 'combo',
- $ref: 'bb',
- name: 'ref2',
- type: 'checkboxes',
- value: 1,
- options: [
- {
- label: 'Option A',
- value: 1
- },
- {
- label: 'Option B',
- value: 2
- }
- ]
- }
+ {
+ type: 'form',
+ api: 'api/xxx',
+ actions: [],
+ controls: [
+ {
+ label: 'text2',
+ $ref: 'aa',
+ name: 'ref1'
+ },
+ {
+ label: 'combo',
+ $ref: 'bb',
+ name: 'ref2',
+ type: 'checkboxes',
+ value: 1,
+ options: [
+ {
+ label: 'Option A',
+ value: 1
+ },
+ {
+ label: 'Option B',
+ value: 2
+ }
]
- }
+ }
+ ]
+ }
]
- }, {
- }, makeEnv({
- })));
+ },
+ {},
+ makeEnv({})
+ )
+ );
- expect(container).toMatchSnapshot();
-});
\ No newline at end of file
+ expect(container).toMatchSnapshot();
+});
diff --git a/__tests__/renderers/Form/__snapshots__/array.test.tsx.snap b/__tests__/renderers/Form/__snapshots__/array.test.tsx.snap
index 95fcdb21..ddc336e2 100644
--- a/__tests__/renderers/Form/__snapshots__/array.test.tsx.snap
+++ b/__tests__/renderers/Form/__snapshots__/array.test.tsx.snap
@@ -36,107 +36,6 @@ exports[`Renderer:array 1`] = `
颜色集合