forked from vuejs/test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.spec.ts
30 lines (25 loc) · 793 Bytes
/
get.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { describe, expect, test } from 'vitest'
import { defineComponent, h } from 'vue'
import { mount } from '../src'
describe('get', () => {
test('returns the element if it exists', () => {
const Component = defineComponent({
render() {
return h('div', {}, [h('span', { id: 'my-span' })])
}
})
const wrapper = mount(Component)
expect(wrapper.get('#my-span')).not.toBeNull()
})
test('throws if it does not exist', () => {
const Component = defineComponent({
render() {
return h('div', {}, [h('span', { id: 'my-span' })])
}
})
const wrapper = mount(Component)
expect(() => wrapper.get('#other-span')).toThrowError(
'Unable to get #other-span within: <div><span id="my-span"></span></div>'
)
})
})