test: Update snapshot

This commit is contained in:
zombiej 2022-04-15 15:39:06 +08:00
parent 67ccf39bd3
commit 15597e1a0e
2 changed files with 30 additions and 91 deletions

View File

@ -87,7 +87,7 @@ describe('Avatar Render', () => {
// https://github.com/jsdom/jsdom/issues/1816
wrapper.find('img').simulate('error');
expect(wrapper).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
expect(div.querySelector('img').getAttribute('src')).toBe(LOAD_SUCCESS_SRC);
wrapper.detach();
@ -105,7 +105,7 @@ describe('Avatar Render', () => {
const wrapper = mount(<Avatar src={LOAD_FAILURE_SRC}>Fallback</Avatar>, { attachTo: div });
wrapper.find('img').simulate('error');
expect(wrapper).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
expect(wrapper.find('.ant-avatar-string').length).toBe(1);
// children should show, when image load error without onError return false
expect(wrapper.find('.ant-avatar-string').prop('style')).not.toHaveProperty('opacity', 0);
@ -114,7 +114,7 @@ describe('Avatar Render', () => {
wrapper.setProps({ src: LOAD_SUCCESS_SRC });
wrapper.update();
expect(wrapper).toMatchSnapshot();
expect(wrapper.render()).toMatchSnapshot();
expect(wrapper.find('.ant-avatar-image').length).toBe(1);
// cleanup
@ -124,7 +124,7 @@ describe('Avatar Render', () => {
it('should calculate scale of avatar children correctly', () => {
const wrapper = mount(<Avatar>Avatar</Avatar>);
expect(wrapper.find('.ant-avatar-string')).toMatchSnapshot();
expect(wrapper.find('.ant-avatar-string').render()).toMatchSnapshot();
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
get() {
@ -135,12 +135,12 @@ describe('Avatar Render', () => {
},
});
wrapper.setProps({ children: 'xx' });
expect(wrapper.find('.ant-avatar-string')).toMatchSnapshot();
expect(wrapper.find('.ant-avatar-string').render()).toMatchSnapshot();
});
it('should calculate scale of avatar children correctly with gap', () => {
const wrapper = mount(<Avatar gap={2}>Avatar</Avatar>);
expect(wrapper.find('.ant-avatar-string')).toMatchSnapshot();
expect(wrapper.find('.ant-avatar-string').render()).toMatchSnapshot();
});
it('should warning when pass a string as icon props', () => {

View File

@ -110,14 +110,8 @@ exports[`Avatar Render rtl render component should be rendered correctly in RTL
exports[`Avatar Render should calculate scale of avatar children correctly 1`] = `
<span
className="ant-avatar-string"
style={
Object {
"WebkitTransform": "scale(0.72) translateX(-50%)",
"msTransform": "scale(0.72) translateX(-50%)",
"transform": "scale(0.72) translateX(-50%)",
}
}
class="ant-avatar-string"
style="transform: scale(0.72) translateX(-50%);"
>
Avatar
</span>
@ -125,14 +119,8 @@ exports[`Avatar Render should calculate scale of avatar children correctly 1`] =
exports[`Avatar Render should calculate scale of avatar children correctly 2`] = `
<span
className="ant-avatar-string"
style={
Object {
"WebkitTransform": "scale(0.72) translateX(-50%)",
"msTransform": "scale(0.72) translateX(-50%)",
"transform": "scale(0.72) translateX(-50%)",
}
}
class="ant-avatar-string"
style="transform: scale(0.72) translateX(-50%);"
>
xx
</span>
@ -140,93 +128,44 @@ exports[`Avatar Render should calculate scale of avatar children correctly 2`] =
exports[`Avatar Render should calculate scale of avatar children correctly with gap 1`] = `
<span
className="ant-avatar-string"
style={
Object {
"WebkitTransform": "scale(0.36) translateX(-50%)",
"msTransform": "scale(0.36) translateX(-50%)",
"transform": "scale(0.36) translateX(-50%)",
}
}
class="ant-avatar-string"
style="transform: scale(0.36) translateX(-50%);"
>
Avatar
</span>
`;
exports[`Avatar Render should handle onError correctly 1`] = `
<Foo>
<Avatar
onError={[Function]}
shape="circle"
size="default"
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://joeschmoe.io/api/v1/random"
>
<span
className="ant-avatar ant-avatar-circle ant-avatar-image"
style={Object {}}
>
<img
onError={[Function]}
src="https://joeschmoe.io/api/v1/random"
/>
</span>
</Avatar>
</Foo>
/>
</span>
`;
exports[`Avatar Render should show image on success after a failure state 1`] = `
<Avatar
shape="circle"
size="default"
src="http://error.url"
<span
class="ant-avatar ant-avatar-circle"
>
<span
className="ant-avatar ant-avatar-circle"
style={Object {}}
class="ant-avatar-string"
style="transform: scale(1) translateX(-50%);"
>
<ResizeObserver
onResize={[Function]}
>
<SingleObserver
key="rc-observer-key-0"
onResize={[Function]}
>
<DomWrapper>
<span
className="ant-avatar-string"
style={
Object {
"WebkitTransform": "scale(1) translateX(-50%)",
"msTransform": "scale(1) translateX(-50%)",
"transform": "scale(1) translateX(-50%)",
}
}
>
Fallback
</span>
</DomWrapper>
</SingleObserver>
</ResizeObserver>
Fallback
</span>
</Avatar>
</span>
`;
exports[`Avatar Render should show image on success after a failure state 2`] = `
<Avatar
shape="circle"
size="default"
src="https://joeschmoe.io/api/v1/random"
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<span
className="ant-avatar ant-avatar-circle ant-avatar-image"
style={Object {}}
>
<img
onError={[Function]}
src="https://joeschmoe.io/api/v1/random"
/>
</span>
</Avatar>
<img
src="https://joeschmoe.io/api/v1/random"
/>
</span>
`;
exports[`Avatar Render support size is number 1`] = `