Skip to content

Commit 8052e3b

Browse files
committed
Improve tests
1 parent 4c05acf commit 8052e3b

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// TypeScript Version: 4.1
1+
// Minimum TypeScript Version: 4.0
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33

44
import {EmitsOptions} from 'vue'

types/test.ts

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {defineComponent, h} from 'vue'
1+
/* eslint-disable @typescript-eslint/no-unused-expressions */
2+
import {defineComponent} from 'vue'
23
import {render, fireEvent, screen, waitFor} from '@testing-library/vue'
34

45
declare const elem: Element
@@ -25,16 +26,18 @@ export async function testRender() {
2526
await page.findAllByText('bar')
2627

2728
// helpers
28-
const {container, unmount, debug, rerender} = page
29+
const {container, baseElement, unmount, debug, rerender} = page
2930

30-
debug(container)
31+
await rerender({a: 1}) // $ExpectType Promise<void>
3132

32-
await rerender({a: 1})
33-
34-
debug(elem) // $ExpectType void
33+
debug() // $ExpectType void
34+
debug(container) // $ExpectType void
3535
debug([elem, elem], 100, {highlight: false}) // $ExpectType void
3636

3737
unmount() // $ExpectType void
38+
39+
container // $ExpectType Element
40+
baseElement // $ExpectType Element
3841
}
3942

4043
export function testRenderOptions() {
@@ -46,31 +49,19 @@ export function testRenderOptions() {
4649

4750
export async function testFireEvent() {
4851
const {container} = render({template: 'button'})
49-
await fireEvent.click(container)
50-
}
51-
52-
export function testDebug() {
53-
const {debug, getAllByTestId} = render({
54-
render() {
55-
return h('div', [
56-
h('h1', {attrs: {'data-testid': 'testid'}}, 'hello world'),
57-
h('h2', {attrs: {'data-testid': 'testid'}}, 'hello world'),
58-
])
59-
},
60-
})
61-
62-
debug(getAllByTestId('testid'))
52+
await fireEvent.click(container) // $ExpectType Promise<void>
53+
await fireEvent.touch(elem) // $ExpectType Promise<void>
6354
}
6455

6556
export async function testScreen() {
6657
render({template: 'button'})
6758

68-
await screen.findByRole('button')
59+
await screen.findByRole('button') // $ExpectType Promise<HTMLElement>
6960
}
7061

7162
export async function testWaitFor() {
7263
const {container} = render({template: 'button'})
73-
await fireEvent.click(container)
64+
await fireEvent.update(container) // $ExpectType Promise<void>
7465
await waitFor(() => {})
7566
}
7667

0 commit comments

Comments
 (0)