test(ellipsis): add ellipsis test (#342)

This commit is contained in:
XieZongChen 2021-07-01 11:09:44 +08:00 committed by GitHub
parent b09818195d
commit 428101eda6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,42 @@
import { mount } from '@vue/test-utils'
import { h } from 'vue'
import { NEllipsis } from '../index'
describe('n-ellipsis', () => {
it('should work with import on demand', () => {
mount(NEllipsis)
})
it('should work with base', async () => {
const wrapper = mount(NEllipsis, {
props: { style: 'max-width: 10px;' },
slots: { default: () => 'test n-ellipsis' }
})
expect(wrapper.find('.n-ellipsis').exists()).toBe(true)
expect(wrapper.find('.n-ellipsis').attributes('style')).toContain(
'text-overflow: ellipsis;'
)
})
it('should work with `line-clamp` prop', async () => {
const wrapper = mount(NEllipsis, {
props: { lineClamp: 2 },
slots: {
default: () => (
<div>
<br />
<br />
</div>
)
}
})
expect(wrapper.find('.n-ellipsis').classes()).toContain(
'n-ellipsis--line-clamp'
)
})
})