mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
test(ellipsis): add ellipsis test (#342)
This commit is contained in:
parent
b09818195d
commit
428101eda6
42
src/ellipsis/tests/Ellipsis.spec.tsx
Normal file
42
src/ellipsis/tests/Ellipsis.spec.tsx
Normal 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'
|
||||
)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user