mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-11-30 02:57:50 +08:00
test: update test
This commit is contained in:
parent
b0025d9e79
commit
e368139cdf
@ -1,11 +1,11 @@
|
|||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { asyncExpect } from '@/tests/utils';
|
import { asyncExpect, sleep } from '@/tests/utils';
|
||||||
import Checkbox from '../index';
|
import Checkbox from '../index';
|
||||||
import mountTest from '../../../tests/shared/mountTest';
|
import mountTest from '../../../tests/shared/mountTest';
|
||||||
|
|
||||||
describe('CheckboxGroup', () => {
|
describe('CheckboxGroup', () => {
|
||||||
mountTest(Checkbox.Group);
|
mountTest(Checkbox.Group);
|
||||||
it('should work basically', () => {
|
it('should work basically', async () => {
|
||||||
const onChange = jest.fn();
|
const onChange = jest.fn();
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
{
|
{
|
||||||
@ -18,12 +18,16 @@ describe('CheckboxGroup', () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
wrapper.findAll('.ant-checkbox-input')[0].trigger('change');
|
wrapper.findAll('.ant-checkbox-input')[0].trigger('change');
|
||||||
|
await sleep();
|
||||||
expect(onChange).toHaveBeenCalledWith(['Apple']);
|
expect(onChange).toHaveBeenCalledWith(['Apple']);
|
||||||
wrapper.findAll('.ant-checkbox-input')[1].trigger('change');
|
wrapper.findAll('.ant-checkbox-input')[1].trigger('change');
|
||||||
|
await sleep();
|
||||||
expect(onChange).toHaveBeenCalledWith(['Apple', 'Pear']);
|
expect(onChange).toHaveBeenCalledWith(['Apple', 'Pear']);
|
||||||
wrapper.findAll('.ant-checkbox-input')[2].trigger('change');
|
wrapper.findAll('.ant-checkbox-input')[2].trigger('change');
|
||||||
|
await sleep();
|
||||||
expect(onChange).toHaveBeenCalledWith(['Apple', 'Pear', 'Orange']);
|
expect(onChange).toHaveBeenCalledWith(['Apple', 'Pear', 'Orange']);
|
||||||
wrapper.findAll('.ant-checkbox-input')[1].trigger('change');
|
wrapper.findAll('.ant-checkbox-input')[1].trigger('change');
|
||||||
|
await sleep();
|
||||||
expect(onChange).toHaveBeenCalledWith(['Apple', 'Orange']);
|
expect(onChange).toHaveBeenCalledWith(['Apple', 'Orange']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { asyncExpect } from '@/tests/utils';
|
import { asyncExpect, sleep } from '@/tests/utils';
|
||||||
import Popconfirm from '..';
|
import Popconfirm from '..';
|
||||||
function $$(className) {
|
function $$(className) {
|
||||||
return document.body.querySelectorAll(className);
|
return document.body.querySelectorAll(className);
|
||||||
@ -73,12 +73,12 @@ describe('Popconfirm', () => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not open in disabled', async () => {
|
fit('should not open in disabled', async () => {
|
||||||
const popconfirm = mount(
|
const popconfirm = mount(
|
||||||
{
|
{
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Popconfirm ref="popconfirm" title="code" disabled>
|
<Popconfirm ref="popconfirm" title="code" disabled={true}>
|
||||||
<span>click me</span>
|
<span>click me</span>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
);
|
);
|
||||||
@ -86,13 +86,9 @@ describe('Popconfirm', () => {
|
|||||||
},
|
},
|
||||||
{ sync: false },
|
{ sync: false },
|
||||||
);
|
);
|
||||||
|
|
||||||
await asyncExpect(() => {
|
|
||||||
popconfirm.find('span').trigger('click');
|
popconfirm.find('span').trigger('click');
|
||||||
}, 1000);
|
popconfirm.vm.$refs.popconfirm.$forceUpdate();
|
||||||
await asyncExpect(() => {
|
|
||||||
const popup = popconfirm.vm.$refs.popconfirm.getPopupDomNode();
|
const popup = popconfirm.vm.$refs.popconfirm.getPopupDomNode();
|
||||||
expect(popup).toBeFalsy();
|
expect(popup).toBeFalsy();
|
||||||
}, 1000);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -119,7 +119,7 @@ const Select = defineComponent({
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
const triggerChange = (...args: any[]) => {
|
const triggerChange = (...args: any[]) => {
|
||||||
emit('update:value', ...args);
|
emit('update:value', args[0]);
|
||||||
emit('change', ...args);
|
emit('change', ...args);
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
|
@ -16,6 +16,11 @@ describe('Tooltip', () => {
|
|||||||
mouseEnterDelay: 0,
|
mouseEnterDelay: 0,
|
||||||
mouseLeaveDelay: 0,
|
mouseLeaveDelay: 0,
|
||||||
onVisibleChange,
|
onVisibleChange,
|
||||||
|
// TODO test/util 的bug 没有使用 v-model 同样会改变
|
||||||
|
'onUpdate:visible': () => {
|
||||||
|
props.visible = this.visible;
|
||||||
|
this.$forceUpdate();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
if (this.visible !== undefined) {
|
if (this.visible !== undefined) {
|
||||||
props.visible = this.visible;
|
props.visible = this.visible;
|
||||||
|
@ -201,8 +201,8 @@ const Base = defineComponent<InternalBlockProps>({
|
|||||||
function onContentChange(value: string) {
|
function onContentChange(value: string) {
|
||||||
const { onChange } = editable.value;
|
const { onChange } = editable.value;
|
||||||
if (value !== props.content) {
|
if (value !== props.content) {
|
||||||
onChange?.(value);
|
|
||||||
emit('update:content', value);
|
emit('update:content', value);
|
||||||
|
onChange?.(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import demo from '../v2-doc/src/docs/typography/demo/index.vue';
|
import demo from '../v2-doc/src/docs/tooltip/demo/index.vue';
|
||||||
// import Affix from '../components/affix';
|
// import Affix from '../components/affix';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
"@vue/compiler-sfc": "^3.0.4",
|
"@vue/compiler-sfc": "^3.0.4",
|
||||||
"@vue/eslint-config-prettier": "^6.0.0",
|
"@vue/eslint-config-prettier": "^6.0.0",
|
||||||
"@vue/eslint-config-typescript": "^7.0.0",
|
"@vue/eslint-config-typescript": "^7.0.0",
|
||||||
"@vue/test-utils": "^2.0.0-beta.2",
|
"@vue/test-utils": "^2.0.0-0",
|
||||||
"acorn": "^7.0.0",
|
"acorn": "^7.0.0",
|
||||||
"autoprefixer": "^9.6.0",
|
"autoprefixer": "^9.6.0",
|
||||||
"axios": "^0.21.0",
|
"axios": "^0.21.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user