Skip to content

Commit 674c297

Browse files
authored
Create dropdown-header.spec.js
1 parent c7bf97a commit 674c297

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import Header from './dropdown-header'
2+
import { mount } from '@vue/test-utils'
3+
4+
describe('dropdown > dropdown-header', () => {
5+
it('works', async () => {
6+
const wrapper = mount(Header)
7+
8+
expect(wrapper.is('h6')).toBe(true)
9+
expect(wrapper.classes()).toContain('dropdown-header')
10+
expect(wrapper.classes().length).toBe(1)
11+
expect(wrapper.attributes('id')).not.toBeDefined()
12+
expect(wrapper.text()).toEqual('')
13+
})
14+
15+
it('renders custom root element when prop tag set', async () => {
16+
const wrapper = mount(Header, {
17+
propsData: {
18+
tag: 'h2'
19+
}
20+
})
21+
22+
expect(wrapper.is('h2')).toBe(true)
23+
expect(wrapper.classes()).toContain('dropdown-header')
24+
expect(wrapper.classes().length).toBe(1)
25+
expect(wrapper.attributes('id')).not.toBeDefined()
26+
expect(wrapper.text()).toEqual('')
27+
})
28+
29+
it('user supplied id when prop id set', async () => {
30+
const wrapper = mount(Header, {
31+
propsData: {
32+
id: 'foo'
33+
}
34+
})
35+
36+
expect(wrapper.is('h6')).toBe(true)
37+
expect(wrapper.classes()).toContain('dropdown-header')
38+
expect(wrapper.classes().length).toBe(1)
39+
expect(wrapper.attributes('id')).toBeDefined()
40+
expect(wrapper.attributes('id')).toEqual('foo')
41+
})
42+
43+
it('renders default slot content', async () => {
44+
const wrapper = mount(Header, {
45+
slots: {
46+
default: 'foobar'
47+
}
48+
})
49+
50+
expect(wrapper.is('h6')).toBe(true)
51+
expect(wrapper.classes()).toContain('dropdown-header')
52+
expect(wrapper.classes().length).toBe(1)
53+
expect(wrapper.text()).toEqual('foobar')
54+
})
55+
})

0 commit comments

Comments
 (0)