From c6a8727d2b685df5ed3bc730d342c6356cdc6e08 Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Wed, 30 May 2018 14:12:43 +0800
Subject: [PATCH] test: update snapshots & some test
---
.../auto-complete/__tests__/index.test.js | 14 +-
components/calendar/__tests__/index.test.js | 21 +-
components/form/demo/advanced-search.vue | 1 -
.../__snapshots__/index.test.js.snap | 236 +++++++++---------
.../locale-provider/__tests__/index.test.js | 6 +-
.../table/__tests__/Table.filter.test.js | 24 +-
.../table/__tests__/Table.pagination.test.js | 8 +-
7 files changed, 165 insertions(+), 145 deletions(-)
diff --git a/components/auto-complete/__tests__/index.test.js b/components/auto-complete/__tests__/index.test.js
index 8ebdc7d3b..97c211040 100644
--- a/components/auto-complete/__tests__/index.test.js
+++ b/components/auto-complete/__tests__/index.test.js
@@ -21,11 +21,15 @@ describe('AutoComplete with Custom Input Element Render', () => {
input.element.value = '123'
input.trigger('input')
Vue.nextTick(() => {
- const popupComponent = wrapper.find({ name: 'Trigger' }).vm._component
- expect($$('.ant-select-dropdown-menu-item').length).toBe(3)
- expect(popupComponent).not.toBe(null)
- expect(popupComponent).not.toBe(undefined)
- done()
+ mount({
+ render () {
+ return wrapper.find({ name: 'Trigger' }).vm.getComponent()
+ },
+ }, { sync: false })
+ Vue.nextTick(() => {
+ expect($$('.ant-select-dropdown-menu-item').length).toBe(3)
+ done()
+ })
})
})
})
diff --git a/components/calendar/__tests__/index.test.js b/components/calendar/__tests__/index.test.js
index a931b3522..6426b3016 100644
--- a/components/calendar/__tests__/index.test.js
+++ b/components/calendar/__tests__/index.test.js
@@ -47,7 +47,8 @@ describe('Calendar', () => {
render () {
return
},
- }
+ },
+ { sync: false }
)
wrapper.findAll('[title="February 20, 2018"]').at(0).trigger('click')
expect(wrapper.find('[title="February 20, 2018"]').classes()).toContain('ant-fullcalendar-disabled-cell')
@@ -85,14 +86,14 @@ describe('Calendar', () => {
{ sync: false }
)
wrapper.find('.ant-fullcalendar-year-select').trigger('click')
- Vue.nextTick(() => {
+ setTimeout(() => {
$$('.ant-select-dropdown-menu-item')[0].click()
wrapper.find('.ant-fullcalendar-month-select').trigger('click')
- Vue.nextTick(() => {
+ setTimeout(() => {
expect($$('.ant-select-dropdown-menu-item').length).toBe(13)
done()
- })
- })
+ }, 1000)
+ }, 1000)
})
it('getDateRange should returns a disabledDate function', () => {
@@ -103,6 +104,7 @@ describe('Calendar', () => {
validRange,
defaultValue: Moment('2018-02-02'),
},
+ sync: false,
}
)
const instance = wrapper.vm
@@ -123,7 +125,7 @@ describe('Calendar', () => {
})
})
- it('Calendar should switch mode', () => {
+ it('Calendar should switch mode', (done) => {
const monthMode = 'month'
const yearMode = 'year'
const onPanelChangeStub = jest.fn()
@@ -140,7 +142,10 @@ describe('Calendar', () => {
)
expect(wrapper.vm.sMode).toEqual(yearMode)
wrapper.vm.setType('date')
- expect(wrapper.vm.sMode).toEqual(monthMode)
- expect(onPanelChangeStub).toHaveBeenCalledTimes(1)
+ Vue.nextTick(() => {
+ expect(wrapper.vm.sMode).toEqual(monthMode)
+ expect(onPanelChangeStub).toHaveBeenCalledTimes(1)
+ done()
+ })
})
})
diff --git a/components/form/demo/advanced-search.vue b/components/form/demo/advanced-search.vue
index 1a2be9e5c..832a7c917 100644
--- a/components/form/demo/advanced-search.vue
+++ b/components/form/demo/advanced-search.vue
@@ -91,7 +91,6 @@ export default {
methods: {
saveFormRef (inst) {
this.formRef = inst
- console.log('formRef', this.formRef)
},
},
render () {
diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap
index 64cba9490..c99588a8d 100644
--- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap
+++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap
@@ -1,6 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Locale Provider set moment locale when locale changes 1`] = `
+
@@ -182,15 +185,15 @@ exports[`Locale Provider set moment locale when locale changes 1`] = `
-
`;
exports[`Locale Provider set moment locale when locale changes 2`] = `
+
-
+
@@ -370,12 +373,12 @@ exports[`Locale Provider set moment locale when locale changes 2`] = `
-
`;
exports[`Locale Provider set moment locale when locale changes 3`] = `
+
@@ -558,9 +561,6 @@ exports[`Locale Provider set moment locale when locale changes 3`] = `
-
`;
exports[`Locale Provider should display the text as ar 1`] = `
@@ -604,12 +604,12 @@ exports[`Locale Provider should display the text as ar 1`] = `
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm
-
- ~
+
+ ~
- Click to confirm
+ Click to confirm