import * as Nerv from 'nervjs'
import * as $ from 'webpack-zepto'
import Badge from '../'
import { VNode } from 'nerv-shared'
describe('Checkbox', () => {
let scratch
beforeAll(() => {
scratch = document.createElement('div')
document.body.appendChild(scratch)
})
beforeEach(() => {
scratch = document.createElement('div')
document.body.appendChild(scratch)
})
afterEach(() => {
scratch.parentNode.removeChild(scratch)
scratch = null
})
it('basic render', () => {
for (let value = -20; value < 20; value++) {
const badge =
const component = Nerv.render(badge as VNode, scratch)
expect(
Number(
$(component.vnode.dom)
.find('.at-badge__content')
.text()
)
).toBe(value)
}
})
it('textContent render', () => {
const value = 'test'
const badge =
const component = Nerv.render(badge as VNode, scratch)
expect(
$(component.vnode.dom)
.find('.at-badge__content')
.text()
).toBe(value)
})
it('different type should have different Color', () => {
const statusList = ['error', 'success', 'warning', 'info']
statusList.forEach((status) => {
const badge =
const component = Nerv.render(badge as VNode, scratch)
expect($(component.vnode.dom).hasClass(`at-badge--${status}`)).toBeTruthy()
})
})
it('over max num limited should render with + ', () => {
const badge =
const component = Nerv.render(badge as VNode, scratch)
expect($(component.vnode.dom).text()).toBe('99+')
})
it('dot render', () => {
const badge =
const component = Nerv.render(badge as VNode, scratch)
expect($(component.vnode.dom).find('.at-badge--dot').length).toBe(1)
})
})