Files
react/components/loading/__tests__/index.test.tsx
Deepankar 9f7968ab3e feat(loading): apply width & height props (#500)
* feat(loading): apply width & height props

* test(loading): test case added & updating snapshots

* fix(loading): add a string type for size prop

test(loading): update test case & snapshots

* feat(loading): support custom the ratio of spaces

* docs(loading): append size and spaceRatio

test(loading): update snapshots

Co-authored-by: unix <unix.bio@gmail.com>
2021-05-03 15:13:33 +08:00

55 lines
1.5 KiB
TypeScript

import React from 'react'
import { mount } from 'enzyme'
import { Loading } from 'components'
describe('Loading', () => {
it('should render correctly', () => {
const wrapper = mount(<Loading />)
expect(wrapper.html()).toMatchSnapshot()
expect(() => wrapper.unmount()).toMatchSnapshot()
})
it('should work with different types', () => {
const wrapper = mount(
<div>
<Loading type="success" />
<Loading type="secondary" />
<Loading type="warning" />
<Loading type="error" />
</div>,
)
expect(wrapper.html()).toMatchSnapshot()
expect(() => wrapper.unmount()).toMatchSnapshot()
})
it('should work with different sizes', () => {
const wrapper = mount(
<div>
<Loading size="mini" />
<Loading size="small" />
<Loading size="medium" />
<Loading size="large" />
</div>,
)
expect(wrapper.html()).toMatchSnapshot()
expect(() => wrapper.unmount()).toMatchSnapshot()
})
it('should work with custom styles', () => {
const wrapper = mount(
<div>
<Loading color="#fff" />
<Loading size="20%" />
<Loading size="10px" />
</div>,
)
expect(wrapper.html()).toMatchSnapshot()
expect(() => wrapper.unmount()).toMatchSnapshot()
})
it('should work with children', () => {
const wrapper = mount(<Loading>test-children</Loading>)
expect(wrapper.find('.loading').text()).toContain('test-children')
})
})