test: update button test
parent
4659dda09e
commit
5f9e8cc59d
|
@ -1,18 +1,56 @@
|
||||||
import Button from '../index'
|
import Button from '../index'
|
||||||
import {mount} from 'avoriaz'
|
import Icon from '../../icon'
|
||||||
|
import { mount } from 'avoriaz'
|
||||||
|
import Vue from 'vue'
|
||||||
|
|
||||||
describe('Button', () => {
|
describe('Button', () => {
|
||||||
let wrapper
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper && wrapper.destroy()
|
|
||||||
})
|
|
||||||
it('create primary button', () => {
|
it('create primary button', () => {
|
||||||
wrapper = mount(Button, {
|
const wrapper = mount({
|
||||||
propsData: {
|
render (h) {
|
||||||
type: 'primary',
|
return <Button type='primary'>按钮</Button>
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
expect(wrapper.hasClass('ant-btn-primary')).to.equal(true)
|
expect(wrapper.hasClass('ant-btn-primary')).to.equal(true)
|
||||||
})
|
})
|
||||||
|
it('renders Chinese characters correctly', (done) => {
|
||||||
|
const wrapper = mount(
|
||||||
|
{
|
||||||
|
render (h) {
|
||||||
|
return <Button>按钮</Button>
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
expect(wrapper.text()).to.equal('按 钮')
|
||||||
|
|
||||||
|
const wrapper1 = mount(
|
||||||
|
{
|
||||||
|
render (h) {
|
||||||
|
return <Button icon='search'>按钮</Button>
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
expect(wrapper1.text()).to.equal('按钮')
|
||||||
|
|
||||||
|
const wrapper2 = mount(
|
||||||
|
{
|
||||||
|
render (h) {
|
||||||
|
return <Button><Icon type="search" />按钮</Button>
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
expect(wrapper2.text()).to.equal('按钮')
|
||||||
|
|
||||||
|
const wrapper3 = mount(
|
||||||
|
{
|
||||||
|
render (h) {
|
||||||
|
return <Button><span>按钮</span></Button>
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
expect(wrapper3.find('.ant-btn')[0].hasClass('ant-btn-two-chinese-chars')).to.equal(true);
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue