From 1d2e634c40c4659bce102d3ecb55db9bcf406cae Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Mon, 11 May 2020 16:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20snapshot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __mocks__/svgMock.js | 5 + __tests__/__snapshots__/factory.test.tsx.snap | 79 +- __tests__/factory.test.tsx | 412 ++--- .../Form/__snapshots__/array.test.tsx.snap | 119 +- .../Form/__snapshots__/button.test.tsx.snap | 102 +- .../__snapshots__/buttonGroup.test.tsx.snap | 66 +- .../__snapshots__/buttonToolBar.test.tsx.snap | 102 +- .../Form/__snapshots__/checkbox.test.tsx.snap | 22 +- .../__snapshots__/checkboxes.test.tsx.snap | 68 +- .../Form/__snapshots__/city.test.tsx.snap | 18 + .../Form/__snapshots__/color.test.tsx.snap | 35 +- .../__snapshots__/container.test.tsx.snap | 23 +- .../Form/__snapshots__/date.test.tsx.snap | 35 +- .../Form/__snapshots__/dateRang.test.tsx.snap | 35 +- .../Form/__snapshots__/datetime.test.tsx.snap | 35 +- .../Form/__snapshots__/fieldSet.test.tsx.snap | 25 +- .../Form/__snapshots__/formula.test.tsx.snap | 18 + .../Form/__snapshots__/grid.test.tsx.snap | 19 + .../Form/__snapshots__/group.test.tsx.snap | 24 + .../Form/__snapshots__/hbox.test.tsx.snap | 19 + .../__snapshots__/iconPicker.test.tsx.snap | 19 + .../Form/__snapshots__/index.test.tsx.snap | 174 +++ .../__snapshots__/inputGroup.test.tsx.snap | 19 + .../Form/__snapshots__/list.test.tsx.snap | 66 +- .../Form/__snapshots__/number.test.tsx.snap | 18 + .../Form/__snapshots__/panel.test.tsx.snap | 108 +- .../Form/__snapshots__/radios.test.tsx.snap | 68 +- .../Form/__snapshots__/range.test.tsx.snap | 70 +- .../Form/__snapshots__/rating.test.tsx.snap | 18 + .../Form/__snapshots__/repeat.test.tsx.snap | 62 +- .../Form/__snapshots__/service.test.tsx.snap | 26 + .../Form/__snapshots__/static.test.tsx.snap | 18 + .../Form/__snapshots__/switch.test.tsx.snap | 18 + .../Form/__snapshots__/tabs.test.tsx.snap | 60 +- .../Form/__snapshots__/testarea.test.tsx.snap | 18 + .../Form/__snapshots__/time.test.tsx.snap | 35 +- .../__snapshots__/Carousel.test.tsx.snap | 28 +- .../__snapshots__/Image.test.tsx.snap | 25 +- .../__snapshots__/Page.test.tsx.snap | 728 ++------- .../__snapshots__/Tabs.test.tsx.snap | 34 +- .../__snapshots__/Wizard.test.tsx.snap | 1367 ++++++++--------- .../stores/__snapshots__/index.test.ts.snap | 14 + .../stores/__snapshots__/service.test.ts.snap | 17 +- .../utils/__snapshots__/api.test.ts.snap | 12 + __tests__/utils/tpl-builtin.test.ts | 1174 +++++++------- examples/components/Page/Form.jsx | 71 +- package.json | 3 +- src/components/icons.tsx | 5 + src/renderers/Form/Checkbox.tsx | 1 - 49 files changed, 2915 insertions(+), 2622 deletions(-) create mode 100644 __mocks__/svgMock.js diff --git a/__mocks__/svgMock.js b/__mocks__/svgMock.js new file mode 100644 index 000000000..57dc8ed7f --- /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 536bd0b72..dc9354cf6 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 95fcdb218..ddc336e2c 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`] = `
颜色集合