Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(comp:badge,icon): fix warning #140

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/components/badge/__tests__/badge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ describe('Badge.vue', () => {
await wrapper.setProps({ count: '1000', overflowCount: 999 })
expect(badge.text()).toBe('999+')
expect(badge.html()).toMatchSnapshot()

const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})

await wrapper.setProps({ count: '1000', overflowCount: '999' })
expect(badge.text()).toBe('999+')
expect(badge.html()).toMatchSnapshot()
await wrapper.setProps({ count: '1000', overflowCount: 'xxx' })
expect(badge.text()).toBe('1000')
expect(badge.html()).toMatchSnapshot()

expect(warn).toBeCalledTimes(2)
})

// 圆点徽标呈现
Expand Down
2 changes: 1 addition & 1 deletion packages/components/icon/src/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function appendChild(props: IconProps, iconConfig: IconConfig, root: Ref<H
: await loadSVGElement(name, iconConfig.loadIconDynamically)
if (svgElement) {
handleRotate(svgElement, rotate)
root.value.appendChild(svgElement)
root.value?.appendChild(svgElement)
}
}
}
Expand Down