2018-06-06 02:48:15 +00:00
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
import { asyncExpect } from '@/tests/utils'
|
|
|
|
import Spin from '..'
|
|
|
|
|
|
|
|
describe('Spin', () => {
|
|
|
|
it('should only affect the spin element when set style to a nested <Spin>xx</Spin>', () => {
|
|
|
|
const wrapper = mount({
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<Spin style={{ background: 'red' }}>
|
|
|
|
<div>content</div>
|
|
|
|
</Spin>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
expect(wrapper.html()).toMatchSnapshot()
|
|
|
|
// expect(wrapper.findAll('.ant-spin-nested-loading').at(0).prop('style')).toBe(null)
|
|
|
|
// expect(wrapper.findAll('.ant-spin').at(0).prop('style').background).toBe('red')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should render custom indicator when it\'s set', () => {
|
|
|
|
// const customIndicator = <div className='custom-indicator' />
|
|
|
|
const wrapper = mount(
|
|
|
|
{
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<Spin><div slot='indicator' class='custom-indicator' /></Spin>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
expect(wrapper.html()).toMatchSnapshot()
|
|
|
|
})
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('should render with delay when it\'s mounted with spinning=true and delay', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
delay: 500,
|
|
|
|
spinning: true,
|
|
|
|
},
|
2018-12-08 04:05:10 +00:00
|
|
|
sync: false,
|
2018-09-05 13:28:54 +00:00
|
|
|
}
|
|
|
|
const wrapper = mount(Spin, props)
|
|
|
|
await asyncExpect(() => {
|
|
|
|
expect(wrapper.find('.ant-spin').classes().includes('ant-spin-spinning')).toEqual(false)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should be controlled by spinning', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
spinning: false,
|
|
|
|
},
|
2018-12-08 04:05:10 +00:00
|
|
|
sync: false,
|
2018-09-05 13:28:54 +00:00
|
|
|
}
|
|
|
|
const wrapper = mount(Spin, props)
|
|
|
|
await asyncExpect(() => {
|
2018-12-08 04:05:10 +00:00
|
|
|
expect(wrapper.vm.sSpinning).toBe(false)
|
2018-09-05 13:28:54 +00:00
|
|
|
wrapper.setProps({ spinning: true })
|
2018-12-08 04:05:10 +00:00
|
|
|
})
|
|
|
|
await asyncExpect(() => {
|
|
|
|
expect(wrapper.vm.sSpinning).toBe(true)
|
2018-09-05 13:28:54 +00:00
|
|
|
})
|
|
|
|
})
|
2018-06-06 02:48:15 +00:00
|
|
|
})
|