From 116c8e4cefcbf30fcbe67493a6ec29f5b694a201 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 20 Jun 2021 22:53:42 +0800 Subject: [PATCH] test: update snap --- components/anchor/Anchor.tsx | 4 +- components/avatar/__tests__/Avatar.test.js | 12 +- .../__snapshots__/Avatar.test.js.snap | 16 +- components/back-top/__tests__/index.test.js | 15 +- components/badge/Badge.tsx | 17 +- .../__snapshots__/index.test.js.snap | 20 +- .../__snapshots__/Breadcrumb.test.js.snap | 2 +- .../__snapshots__/index.test.js.snap | 6 +- .../__snapshots__/index.test.js.snap | 4 +- .../__snapshots__/index.test.js.snap | 30 +- .../__snapshots__/index.test.js.snap | 2 +- .../__snapshots__/index.test.js.snap | 19 +- .../__snapshots__/DatePicker.test.js.snap | 2 +- .../__snapshots__/RangePicker.test.js.snap | 4 +- .../__snapshots__/other.test.js.snap | 8 +- .../__snapshots__/Drawer.test.js.snap | 8 +- .../__snapshots__/DrawerEvent.test.js.snap | 2 +- .../dropdown-button.test.js.snap | 2 +- components/form/context.ts | 3 + .../__snapshots__/index.test.js.snap | 2 +- components/layout/Sider.tsx | 2 +- .../__snapshots__/index.test.js.snap | 1428 ++++++++--------- .../__snapshots__/Modal.test.js.snap | 6 +- 23 files changed, 812 insertions(+), 802 deletions(-) diff --git a/components/anchor/Anchor.tsx b/components/anchor/Anchor.tsx index 62e599f27..41772337b 100644 --- a/components/anchor/Anchor.tsx +++ b/components/anchor/Anchor.tsx @@ -88,7 +88,7 @@ export default defineComponent({ scrollEvent: null, animating: false, }); - const activeLink = ref(); + const activeLink = ref(null); const getContainer = computed(() => { const { getContainer } = props; return getContainer || getTargetContainer.value || getDefaultContainer; @@ -122,7 +122,7 @@ export default defineComponent({ }; const setCurrentActiveLink = (link: string) => { const { getCurrentAnchor } = props; - if (activeLink.value !== link) { + if (activeLink.value === link) { return; } activeLink.value = typeof getCurrentAnchor === 'function' ? getCurrentAnchor() : link; diff --git a/components/avatar/__tests__/Avatar.test.js b/components/avatar/__tests__/Avatar.test.js index 91d028d39..f9537dba0 100644 --- a/components/avatar/__tests__/Avatar.test.js +++ b/components/avatar/__tests__/Avatar.test.js @@ -186,7 +186,7 @@ describe('Avatar Render', () => { }); }); - it('fallback', async () => { + it('fallback', () => { const div = global.document.createElement('div'); global.document.body.appendChild(div); const wrapper = mount( @@ -201,11 +201,9 @@ describe('Avatar Render', () => { }, { attachTo: div }, ); - await asyncExpect(async () => { - await wrapper.find('img').trigger('error'); - expect(wrapper.html()).toMatchSnapshot(); - wrapper.unmount(); - global.document.body.removeChild(div); - }, 0); + wrapper.find('img').trigger('error'); + expect(wrapper.html()).toMatchSnapshot(); + wrapper.unmount(); + global.document.body.removeChild(div); }); }); diff --git a/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap b/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap index a17048216..df10ee4ee 100644 --- a/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap +++ b/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap @@ -1,18 +1,18 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Avatar Render adjusts component size to 24 when window size is xs 1`] = ``; +exports[`Avatar Render adjusts component size to 24 when window size is xs 1`] = ``; -exports[`Avatar Render adjusts component size to 32 when window size is sm 1`] = ``; +exports[`Avatar Render adjusts component size to 32 when window size is sm 1`] = ``; -exports[`Avatar Render adjusts component size to 40 when window size is md 1`] = ``; +exports[`Avatar Render adjusts component size to 40 when window size is md 1`] = ``; -exports[`Avatar Render adjusts component size to 64 when window size is lg 1`] = ``; +exports[`Avatar Render adjusts component size to 64 when window size is lg 1`] = ``; -exports[`Avatar Render adjusts component size to 80 when window size is xl 1`] = ``; +exports[`Avatar Render adjusts component size to 80 when window size is xl 1`] = ``; -exports[`Avatar Render adjusts component size to 100 when window size is xxl 1`] = ``; +exports[`Avatar Render adjusts component size to 100 when window size is xxl 1`] = ``; -exports[`Avatar Render fallback 1`] = `A`; +exports[`Avatar Render fallback 1`] = ``; exports[`Avatar Render should calculate scale of avatar children correctly 1`] = ` DOMWrapper { @@ -40,4 +40,4 @@ DOMWrapper { } `; -exports[`Avatar Render should calculate scale of avatar children correctly with gap 1`] = `Avatar`; +exports[`Avatar Render should calculate scale of avatar children correctly with gap 1`] = `Avatar`; diff --git a/components/back-top/__tests__/index.test.js b/components/back-top/__tests__/index.test.js index 791bf4cef..b7a4c3cbf 100644 --- a/components/back-top/__tests__/index.test.js +++ b/components/back-top/__tests__/index.test.js @@ -8,18 +8,19 @@ describe('BackTop', () => { props: { visibilityHeight: -1, }, + attachTo: 'body', }); const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => { window.scrollY = y; window.pageYOffset = y; + document.documentElement.scrollTop = y; }); window.scrollTo(0, 400); - // trigger scroll manually - wrapper.vm.handleScroll(); - await sleep(); + expect(document.documentElement.scrollTop).toBe(400); + await sleep(10); wrapper.find('.ant-back-top').trigger('click'); await sleep(500); - expect(window.pageYOffset).toBe(0); + expect(document.documentElement.scrollTop).toBe(0); scrollToSpy.mockRestore(); }); it('support onClick', async () => { @@ -29,15 +30,15 @@ describe('BackTop', () => { visibilityHeight: -1, onClick, }, + attachTo: 'body', }); const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => { window.scrollY = y; window.pageYOffset = y; }); + document.dispatchEvent(new Event('scroll')); window.scrollTo(0, 400); - // trigger scroll manually - wrapper.vm.handleScroll(); - await sleep(); + await sleep(10); wrapper.find('.ant-back-top').trigger('click'); expect(onClick).toHaveBeenCalled(); scrollToSpy.mockRestore(); diff --git a/components/badge/Badge.tsx b/components/badge/Badge.tsx index e3d5aa57b..6e16cf613 100644 --- a/components/badge/Badge.tsx +++ b/components/badge/Badge.tsx @@ -157,13 +157,16 @@ export default defineComponent({ visible || !text ? null : {text}; // >>> Display Component - const displayNode = cloneElement( - slots.count?.(), - { - style: mergedStyle, - }, - false, - ); + const displayNode = + typeof count === 'object' || (count === undefined && slots.count) + ? cloneElement( + count ?? slots.count?.(), + { + style: mergedStyle, + }, + false, + ) + : null; const badgeClassName = classNames( pre, diff --git a/components/badge/__tests__/__snapshots__/index.test.js.snap b/components/badge/__tests__/__snapshots__/index.test.js.snap index db5754c14..5d9c546ac 100644 --- a/components/badge/__tests__/__snapshots__/index.test.js.snap +++ b/components/badge/__tests__/__snapshots__/index.test.js.snap @@ -2,47 +2,47 @@ exports[`Badge badge should support float number 1`] = `"3.5"`; -exports[`Badge badge should support float number 2`] = `3.5`; +exports[`Badge badge should support float number 2`] = `3.5`; exports[`Badge render correct with negative number 1`] = ` -
-

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

-
-

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

-

1

0

+

-

1

0

`; exports[`Badge should be compatible with borderColor style 1`] = ` -

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

4

`; exports[`Badge should render when count is changed 1`] = ` -

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

1

0

1

2

3

4

5

6

7

8

9

0

`; exports[`Badge should render when count is changed 2`] = ` -

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

1

1

2

3

4

5

6

7

8

9

0

1

`; exports[`Badge should render when count is changed 3`] = ` -

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

1

1

2

3

4

5

6

7

8

9

0

1

`; exports[`Badge should render when count is changed 4`] = ` -

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

1

0

1

2

3

4

5

6

7

8

9

0

`; exports[`Badge should render when count is changed 5`] = ` -

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

9

`; exports[`Badge should support offset when count is a VueNode 1`] = ` -head +head `; diff --git a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap index e0ffda91b..ca021ed63 100644 --- a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap +++ b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap @@ -8,7 +8,7 @@ exports[`Breadcrumb should not display Breadcrumb Item when its children is fals
`; -exports[`Breadcrumb should render a menu 1`] = `
home/first/second/
`; +exports[`Breadcrumb should render a menu 1`] = `
home/first/second/
`; exports[`Breadcrumb should support Breadcrumb.Item default separator 1`] = `
Location/Mock Node/Application Center/
`; diff --git a/components/button/__tests__/__snapshots__/index.test.js.snap b/components/button/__tests__/__snapshots__/index.test.js.snap index 845b99e3a..c97904fa7 100644 --- a/components/button/__tests__/__snapshots__/index.test.js.snap +++ b/components/button/__tests__/__snapshots__/index.test.js.snap @@ -26,7 +26,7 @@ exports[`Button renders Chinese characters correctly 1`] = ` exports[`Button renders Chinese characters correctly 2`] = ` `; @@ -36,9 +36,9 @@ exports[`Button renders Chinese characters correctly 3`] = ` `; -exports[`Button renders Chinese characters correctly 4`] = ``; +exports[`Button renders Chinese characters correctly 4`] = ``; -exports[`Button renders Chinese characters correctly 5`] = ``; +exports[`Button renders Chinese characters correctly 5`] = ``; exports[`Button renders Chinese characters correctly 6`] = ` - - +
+
+
+ +
diff --git a/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap b/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap index 5330b1d73..ab0e80988 100644 --- a/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`DatePicker prop locale should works 1`] = `
`; +exports[`DatePicker prop locale should works 1`] = `
`; diff --git a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap index ffee840c4..a5dea2f8a 100644 --- a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`RangePicker show month panel according to value 1`] = ` -
~ +
~
@@ -383,7 +383,7 @@ exports[`RangePicker show month panel according to value 1`] = ` `; exports[`RangePicker switch to corresponding month panel when click presetted ranges 1`] = ` - ~ + ~
diff --git a/components/date-picker/__tests__/__snapshots__/other.test.js.snap b/components/date-picker/__tests__/__snapshots__/other.test.js.snap index 016d246dd..109ca994d 100644 --- a/components/date-picker/__tests__/__snapshots__/other.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/other.test.js.snap @@ -242,10 +242,10 @@ exports[`MonthPicker and WeekPicker render WeekPicker 1`] = `
`; -exports[`Picker format by locale date 1`] = `
`; +exports[`Picker format by locale date 1`] = `
`; -exports[`Picker format by locale dateTime 1`] = `
`; +exports[`Picker format by locale dateTime 1`] = `
`; -exports[`Picker format by locale month 1`] = `
`; +exports[`Picker format by locale month 1`] = `
`; -exports[`Picker format by locale week 1`] = ``; +exports[`Picker format by locale week 1`] = ``; diff --git a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap index b378e63b2..be9a17201 100644 --- a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap @@ -8,7 +8,7 @@ exports[`Drawer class is test_drawer 1`] = `
- +
Here is content of Drawer
@@ -61,7 +61,7 @@ exports[`Drawer have a title 1`] = `
-
Test Title
+
Test Title
Here is content of Drawer
@@ -80,7 +80,7 @@ exports[`Drawer render correctly 1`] = `
- +
Here is content of Drawer
@@ -99,7 +99,7 @@ exports[`Drawer render top drawer 1`] = `
- +
Here is content of Drawer
diff --git a/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap b/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap index 684bf6b56..2f0490811 100644 --- a/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap @@ -11,7 +11,7 @@ exports[`Drawer render correctly 1`] = `
- +
Here is content of Drawer
diff --git a/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap b/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap index 0b1054b83..eb54d577c 100644 --- a/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap +++ b/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap @@ -5,7 +5,7 @@ exports[`DropdownButton should support href like Button 1`] = `
`; diff --git a/components/form/context.ts b/components/form/context.ts index 00f95342e..d89fadc24 100644 --- a/components/form/context.ts +++ b/components/form/context.ts @@ -34,6 +34,9 @@ export const useInjectForm = () => { addField: (_eventKey: string, _field: FieldExpose) => {}, // eslint-disable-next-line @typescript-eslint/no-unused-vars removeField: (_eventKey: string) => {}, + model: computed(() => undefined), + rules: computed(() => undefined), + requiredMark: computed(() => false), }); }; diff --git a/components/input/__tests__/__snapshots__/index.test.js.snap b/components/input/__tests__/__snapshots__/index.test.js.snap index 9da98deac..2209f9c4d 100644 --- a/components/input/__tests__/__snapshots__/index.test.js.snap +++ b/components/input/__tests__/__snapshots__/index.test.js.snap @@ -2,7 +2,7 @@ exports[`Input should support maxlength 1`] = ``; -exports[`Input.Search should support suffix 1`] = `suffix`; +exports[`Input.Search should support suffix 1`] = `suffix`; exports[`TextArea should support disabled 1`] = ``; diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index 80f1f121e..bf67b7a3f 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -81,7 +81,7 @@ export default defineComponent({ emits: ['breakpoint', 'update:collapsed', 'collapse'], setup(props, { emit, attrs, slots }) { const { prefixCls } = useConfigInject('layout-sider', props); - const siderHook = inject(SiderHookProviderKey); + const siderHook = inject(SiderHookProviderKey, undefined); const collapsed = ref( !!(props.collapsed !== undefined ? props.collapsed : props.defaultCollapsed), ); diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap index 0a9a3a5fd..e7de8ecd5 100644 --- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap +++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap @@ -580,20 +580,20 @@ exports[`Locale Provider should display the text as ar 1`] = `
    -
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • -
  • +
  • 10 / الصفحة -
    +
@@ -604,23 +604,23 @@ exports[`Locale Provider should display the text as ar 1`] = `
-
+
-
+
- + ~ Click to confirm
-