mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-11-30 02:57:50 +08:00
test: update avatar
This commit is contained in:
parent
4f3e307f12
commit
f4ffe3cf6a
@ -26,7 +26,7 @@ describe('Avatar Render', () => {
|
|||||||
it('Render long string correctly', () => {
|
it('Render long string correctly', () => {
|
||||||
const wrapper = mount(Avatar, {
|
const wrapper = mount(Avatar, {
|
||||||
slots: {
|
slots: {
|
||||||
default: 'TestString',
|
default: () => 'TestString',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const children = wrapper.findAll('.ant-avatar-string');
|
const children = wrapper.findAll('.ant-avatar-string');
|
||||||
@ -36,7 +36,7 @@ describe('Avatar Render', () => {
|
|||||||
global.document.body.innerHTML = '';
|
global.document.body.innerHTML = '';
|
||||||
const wrapper = mount(Avatar, {
|
const wrapper = mount(Avatar, {
|
||||||
slots: {
|
slots: {
|
||||||
default: 'Fallback',
|
default: () => 'Fallback',
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
src: 'http://error.url',
|
src: 'http://error.url',
|
||||||
@ -48,7 +48,7 @@ describe('Avatar Render', () => {
|
|||||||
if (wrapper.vm.scale === 0.5) {
|
if (wrapper.vm.scale === 0.5) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wrapper.setData({ scale: 0.5 });
|
wrapper.vm.scale = 0.5;
|
||||||
wrapper.vm.$forceUpdate();
|
wrapper.vm.$forceUpdate();
|
||||||
});
|
});
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
@ -57,7 +57,7 @@ describe('Avatar Render', () => {
|
|||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
const children = wrapper.findAll('.ant-avatar-string');
|
const children = wrapper.findAll('.ant-avatar-string');
|
||||||
expect(children.length).toBe(1);
|
expect(children.length).toBe(1);
|
||||||
expect(children.at(0).text()).toBe('Fallback');
|
expect(children[0].text()).toBe('Fallback');
|
||||||
expect(wrapper.vm.setScale).toHaveBeenCalled();
|
expect(wrapper.vm.setScale).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
@ -98,7 +98,7 @@ describe('Avatar Render', () => {
|
|||||||
wrapper.find('img').trigger('error');
|
wrapper.find('img').trigger('error');
|
||||||
}, 0);
|
}, 0);
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
expect(wrapper.find({ name: 'AAvatar' }).vm.isImgExist).toBe(true);
|
expect(wrapper.findComponent({ name: 'AAvatar' }).vm.isImgExist).toBe(true);
|
||||||
}, 0);
|
}, 0);
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
expect(global.document.body.querySelector('img').getAttribute('src')).toBe(LOAD_SUCCESS_SRC);
|
expect(global.document.body.querySelector('img').getAttribute('src')).toBe(LOAD_SUCCESS_SRC);
|
||||||
@ -128,15 +128,15 @@ describe('Avatar Render', () => {
|
|||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
expect(wrapper.find({ name: 'AAvatar' }).vm.isImgExist).toBe(false);
|
expect(wrapper.findComponent({ name: 'AAvatar' }).vm.isImgExist).toBe(false);
|
||||||
expect(wrapper.findAll('.ant-avatar-string').length).toBe(1);
|
expect(wrapper.findAll('.ant-avatar-string').length).toBe(1);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
wrapper.setData({ src: LOAD_SUCCESS_SRC });
|
wrapper.vm.src = LOAD_SUCCESS_SRC;
|
||||||
});
|
});
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
expect(wrapper.find({ name: 'AAvatar' }).vm.isImgExist).toBe(true);
|
expect(wrapper.findComponent({ name: 'AAvatar' }).vm.isImgExist).toBe(true);
|
||||||
expect(wrapper.findAll('.ant-avatar-image').length).toBe(1);
|
expect(wrapper.findAll('.ant-avatar-image').length).toBe(1);
|
||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user