-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathrender-utilities.test-d.ts
65 lines (55 loc) · 1.81 KB
/
render-utilities.test-d.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { expectTypeOf } from 'expect-type'
import { describe, test } from 'vitest'
import * as subject from '../index.js'
import Component from './fixtures/Comp.svelte'
describe('render query and utility types', () => {
test('render result has default queries', () => {
const result = subject.render(Component, { name: 'Alice' })
expectTypeOf(result.getByRole).parameters.toExtend<
[role: subject.ByRoleMatcher, options?: subject.ByRoleOptions]
>()
})
test('render result can have custom queries', () => {
const [getByVibes] = subject.buildQueries(
(_container: HTMLElement, vibes: string) => {
throw new Error(`unimplemented ${vibes}`)
},
() => '',
() => ''
)
const result = subject.render(
Component,
{ name: 'Alice' },
{ queries: { getByVibes } }
)
expectTypeOf(result.getByVibes).parameters.toExtend<[vibes: string]>()
})
test('act is an async function', () => {
expectTypeOf(subject.act).toExtend<() => Promise<void>>()
})
test('act accepts a sync function', () => {
expectTypeOf(subject.act).toExtend<(fn: () => void) => Promise<void>>()
})
test('act accepts an async function', () => {
expectTypeOf(subject.act).toExtend<
(fn: () => Promise<void>) => Promise<void>
>()
})
test('fireEvent is an async function', () => {
expectTypeOf(subject.fireEvent).toExtend<
(
element: Element | Node | Document | Window,
event: Event
) => Promise<boolean>
>()
})
test('fireEvent[eventName] is an async function', () => {
expectTypeOf(subject.fireEvent.click).toExtend<
(
element: Element | Node | Document | Window,
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
options?: {}
) => Promise<boolean>
>()
})
})