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 // https://github.com/jsdom/jsdom/issues/1816
wrapper.find('img').simulate('error'); wrapper.find('img').simulate('error');
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
expect(div.querySelector('img').getAttribute('src')).toBe(LOAD_SUCCESS_SRC); expect(div.querySelector('img').getAttribute('src')).toBe(LOAD_SUCCESS_SRC);
wrapper.detach(); wrapper.detach();
@ -105,7 +105,7 @@ describe('Avatar Render', () => {
const wrapper = mount(<Avatar src={LOAD_FAILURE_SRC}>Fallback</Avatar>, { attachTo: div }); const wrapper = mount(<Avatar src={LOAD_FAILURE_SRC}>Fallback</Avatar>, { attachTo: div });
wrapper.find('img').simulate('error'); wrapper.find('img').simulate('error');
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
expect(wrapper.find('.ant-avatar-string').length).toBe(1); expect(wrapper.find('.ant-avatar-string').length).toBe(1);
// children should show, when image load error without onError return false // children should show, when image load error without onError return false
expect(wrapper.find('.ant-avatar-string').prop('style')).not.toHaveProperty('opacity', 0); 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.setProps({ src: LOAD_SUCCESS_SRC });
wrapper.update(); wrapper.update();
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
expect(wrapper.find('.ant-avatar-image').length).toBe(1); expect(wrapper.find('.ant-avatar-image').length).toBe(1);
// cleanup // cleanup
@ -124,7 +124,7 @@ describe('Avatar Render', () => {
it('should calculate scale of avatar children correctly', () => { it('should calculate scale of avatar children correctly', () => {
const wrapper = mount(<Avatar>Avatar</Avatar>); 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', { Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
get() { get() {
@ -135,12 +135,12 @@ describe('Avatar Render', () => {
}, },
}); });
wrapper.setProps({ children: 'xx' }); 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', () => { it('should calculate scale of avatar children correctly with gap', () => {
const wrapper = mount(<Avatar gap={2}>Avatar</Avatar>); 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', () => { 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`] = ` exports[`Avatar Render should calculate scale of avatar children correctly 1`] = `
<span <span
className="ant-avatar-string" class="ant-avatar-string"
style={ style="transform: scale(0.72) translateX(-50%);"
Object {
"WebkitTransform": "scale(0.72) translateX(-50%)",
"msTransform": "scale(0.72) translateX(-50%)",
"transform": "scale(0.72) translateX(-50%)",
}
}
> >
Avatar Avatar
</span> </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`] = ` exports[`Avatar Render should calculate scale of avatar children correctly 2`] = `
<span <span
className="ant-avatar-string" class="ant-avatar-string"
style={ style="transform: scale(0.72) translateX(-50%);"
Object {
"WebkitTransform": "scale(0.72) translateX(-50%)",
"msTransform": "scale(0.72) translateX(-50%)",
"transform": "scale(0.72) translateX(-50%)",
}
}
> >
xx xx
</span> </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`] = ` exports[`Avatar Render should calculate scale of avatar children correctly with gap 1`] = `
<span <span
className="ant-avatar-string" class="ant-avatar-string"
style={ style="transform: scale(0.36) translateX(-50%);"
Object {
"WebkitTransform": "scale(0.36) translateX(-50%)",
"msTransform": "scale(0.36) translateX(-50%)",
"transform": "scale(0.36) translateX(-50%)",
}
}
> >
Avatar Avatar
</span> </span>
`; `;
exports[`Avatar Render should handle onError correctly 1`] = ` exports[`Avatar Render should handle onError correctly 1`] = `
<Foo> <span
<Avatar class="ant-avatar ant-avatar-circle ant-avatar-image"
onError={[Function]} >
shape="circle" <img
size="default"
src="https://joeschmoe.io/api/v1/random" src="https://joeschmoe.io/api/v1/random"
> />
<span </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>
`; `;
exports[`Avatar Render should show image on success after a failure state 1`] = ` exports[`Avatar Render should show image on success after a failure state 1`] = `
<Avatar <span
shape="circle" class="ant-avatar ant-avatar-circle"
size="default"
src="http://error.url"
> >
<span <span
className="ant-avatar ant-avatar-circle" class="ant-avatar-string"
style={Object {}} style="transform: scale(1) translateX(-50%);"
> >
<ResizeObserver Fallback
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>
</span> </span>
</Avatar> </span>
`; `;
exports[`Avatar Render should show image on success after a failure state 2`] = ` exports[`Avatar Render should show image on success after a failure state 2`] = `
<Avatar <span
shape="circle" class="ant-avatar ant-avatar-circle ant-avatar-image"
size="default"
src="https://joeschmoe.io/api/v1/random"
> >
<span <img
className="ant-avatar ant-avatar-circle ant-avatar-image" src="https://joeschmoe.io/api/v1/random"
style={Object {}} />
> </span>
<img
onError={[Function]}
src="https://joeschmoe.io/api/v1/random"
/>
</span>
</Avatar>
`; `;
exports[`Avatar Render support size is number 1`] = ` exports[`Avatar Render support size is number 1`] = `