Skip to content

Commit e368139

Browse files
committed
test: update test
1 parent b0025d9 commit e368139

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

components/checkbox/__tests__/group.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { mount } from '@vue/test-utils';
2-
import { asyncExpect } from '@/tests/utils';
2+
import { asyncExpect, sleep } from '@/tests/utils';
33
import Checkbox from '../index';
44
import mountTest from '../../../tests/shared/mountTest';
55

66
describe('CheckboxGroup', () => {
77
mountTest(Checkbox.Group);
8-
it('should work basically', () => {
8+
it('should work basically', async () => {
99
const onChange = jest.fn();
1010
const wrapper = mount(
1111
{
@@ -18,12 +18,16 @@ describe('CheckboxGroup', () => {
1818
},
1919
);
2020
wrapper.findAll('.ant-checkbox-input')[0].trigger('change');
21+
await sleep();
2122
expect(onChange).toHaveBeenCalledWith(['Apple']);
2223
wrapper.findAll('.ant-checkbox-input')[1].trigger('change');
24+
await sleep();
2325
expect(onChange).toHaveBeenCalledWith(['Apple', 'Pear']);
2426
wrapper.findAll('.ant-checkbox-input')[2].trigger('change');
27+
await sleep();
2528
expect(onChange).toHaveBeenCalledWith(['Apple', 'Pear', 'Orange']);
2629
wrapper.findAll('.ant-checkbox-input')[1].trigger('change');
30+
await sleep();
2731
expect(onChange).toHaveBeenCalledWith(['Apple', 'Orange']);
2832
});
2933

components/popconfirm/__tests__/index.test.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mount } from '@vue/test-utils';
2-
import { asyncExpect } from '@/tests/utils';
2+
import { asyncExpect, sleep } from '@/tests/utils';
33
import Popconfirm from '..';
44
function $$(className) {
55
return document.body.querySelectorAll(className);
@@ -73,26 +73,22 @@ describe('Popconfirm', () => {
7373
}, 1000);
7474
});
7575

76-
it('should not open in disabled', async () => {
76+
fit('should not open in disabled', async () => {
7777
const popconfirm = mount(
7878
{
7979
render() {
8080
return (
81-
<Popconfirm ref="popconfirm" title="code" disabled>
81+
<Popconfirm ref="popconfirm" title="code" disabled={true}>
8282
<span>click me</span>
8383
</Popconfirm>
8484
);
8585
},
8686
},
8787
{ sync: false },
8888
);
89-
90-
await asyncExpect(() => {
91-
popconfirm.find('span').trigger('click');
92-
}, 1000);
93-
await asyncExpect(() => {
94-
const popup = popconfirm.vm.$refs.popconfirm.getPopupDomNode();
95-
expect(popup).toBeFalsy();
96-
}, 1000);
89+
popconfirm.find('span').trigger('click');
90+
popconfirm.vm.$refs.popconfirm.$forceUpdate();
91+
const popup = popconfirm.vm.$refs.popconfirm.getPopupDomNode();
92+
expect(popup).toBeFalsy();
9793
});
9894
});

components/select/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const Select = defineComponent({
119119
),
120120
);
121121
const triggerChange = (...args: any[]) => {
122-
emit('update:value', ...args);
122+
emit('update:value', args[0]);
123123
emit('change', ...args);
124124
};
125125
return {

components/tooltip/__tests__/tooltip.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ describe('Tooltip', () => {
1616
mouseEnterDelay: 0,
1717
mouseLeaveDelay: 0,
1818
onVisibleChange,
19+
// TODO test/util 的bug 没有使用 v-model 同样会改变
20+
'onUpdate:visible': () => {
21+
props.visible = this.visible;
22+
this.$forceUpdate();
23+
},
1924
};
2025
if (this.visible !== undefined) {
2126
props.visible = this.visible;

components/typography/Base.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ const Base = defineComponent<InternalBlockProps>({
201201
function onContentChange(value: string) {
202202
const { onChange } = editable.value;
203203
if (value !== props.content) {
204-
onChange?.(value);
205204
emit('update:content', value);
205+
onChange?.(value);
206206
}
207207
}
208208

examples/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66
<script>
77
import { defineComponent } from 'vue';
8-
import demo from '../v2-doc/src/docs/typography/demo/index.vue';
8+
import demo from '../v2-doc/src/docs/tooltip/demo/index.vue';
99
// import Affix from '../components/affix';
1010
export default defineComponent({
1111
components: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"@vue/compiler-sfc": "^3.0.4",
9595
"@vue/eslint-config-prettier": "^6.0.0",
9696
"@vue/eslint-config-typescript": "^7.0.0",
97-
"@vue/test-utils": "^2.0.0-beta.2",
97+
"@vue/test-utils": "^2.0.0-0",
9898
"acorn": "^7.0.0",
9999
"autoprefixer": "^9.6.0",
100100
"axios": "^0.21.0",

0 commit comments

Comments
 (0)