Files
react/components/button/__tests__/icon.test.tsx
witt 7facec3849 feat(scaleable): add scaleable props to each component (#531)
* feat(scaleable): add scaleable props to each component

* chore(scaleable): update the exported type

* feat: apply scaleable to components

chore: remove with-default

test: improve testcase for scaleable

chore: resolve test warning

ci: upgrade nodejs to latest lts

docs: fix type error in document site

* docs: update documents to be compatible with scaleable

chore: fix build errors

* chore: remove all size-related attributes

docs: improve guide document

* docs: add scaleable documentation

test: update snapshots

chore: remove unused

* feat: add scaleable to grid components

* docs: improve docs

* test: update snapshots

* fix(grid): fix basic component props
2021-08-13 17:10:57 +08:00

49 lines
1.5 KiB
TypeScript

import React from 'react'
import { mount } from 'enzyme'
import { Button } from 'components'
const Icon: React.FC<any> = () => <svg />
describe('ButtonIcon', () => {
it('should render correctly', () => {
const wrapper = mount(<Button icon={<Icon />}>action</Button>)
expect(wrapper.html()).toMatchSnapshot()
expect(() => wrapper.unmount()).not.toThrow()
})
it('should work with right', () => {
const wrapper = mount(<Button iconRight={<Icon />}>action</Button>)
expect(wrapper.html()).toMatchSnapshot()
expect(() => wrapper.unmount()).not.toThrow()
})
it('should work without text', () => {
const wrapper = mount(<Button iconRight={<Icon />} />)
const text = wrapper.find('.text')
expect(wrapper.html()).toMatchSnapshot()
expect(text.length).toBe(0)
})
it('the width of the text should be filled', () => {
const autoWrapper = mount(
<Button auto icon={<Icon />}>
action
</Button>,
)
const wrapper = mount(<Button icon={<Icon />}>action</Button>)
const autoHtml = autoWrapper.find('.text').html()
const html = wrapper.find('.text').html()
expect(html).not.toEqual(autoHtml)
const mini = mount(<Button>action</Button>)
const miniIcon = mount(
<Button scale={2} icon={<Icon />}>
action
</Button>,
)
const miniHtml = mini.find('.text').html()
const miniIconHtml = miniIcon.find('.text').html()
expect(miniHtml).not.toEqual(miniIconHtml)
})
})