@@ -2,99 +2,99 @@ import {setupBrowser} from '../src';
2
2
3
3
describe ( 'queries' , ( ) => {
4
4
it ( 'queryBy resolves with matching element' , async ( ) => {
5
- const { queryByText} = await setupBrowser ( browser )
5
+ const { queryByText} = setupBrowser ( browser )
6
6
7
7
const button = await queryByText ( 'Unique Button Text' )
8
8
expect ( await button ?. getText ( ) ) . toEqual ( 'Unique Button Text' )
9
9
} )
10
10
11
11
it ( 'queryBy resolves with null when there are no matching elements' , async ( ) => {
12
- const { queryByText} = await setupBrowser ( browser )
12
+ const { queryByText} = setupBrowser ( browser )
13
13
14
14
const button = await queryByText ( 'Text that does not exist' )
15
15
expect ( button ) . toBeNull ( )
16
16
} )
17
17
18
18
it ( 'getBy resolves with matching element' , async ( ) => {
19
- const { getByText} = await setupBrowser ( browser )
19
+ const { getByText} = setupBrowser ( browser )
20
20
21
21
const button = await getByText ( 'Unique Button Text' )
22
22
expect ( await button . getText ( ) ) . toEqual ( 'Unique Button Text' )
23
23
} )
24
24
25
25
it ( 'getBy rejects when there are no matching elements' , async ( ) => {
26
- const { getByText} = await setupBrowser ( browser )
26
+ const { getByText} = setupBrowser ( browser )
27
27
28
28
await expect ( getByText ( 'Text that does not exist' ) ) . rejects . toThrow ( )
29
29
} )
30
30
31
31
it ( 'getBy rejects when there are multiple matching elements' , async ( ) => {
32
- const { getByText} = await setupBrowser ( browser )
32
+ const { getByText} = setupBrowser ( browser )
33
33
34
34
await expect ( getByText ( 'Button Text' ) ) . rejects . toThrow ( )
35
35
} )
36
36
37
37
it ( 'findBy waits for matching element and resolves with it' , async ( ) => {
38
- const { findByText} = await setupBrowser ( browser )
38
+ const { findByText} = setupBrowser ( browser )
39
39
40
40
const button = await findByText ( 'Unique Delayed Button Text' )
41
41
expect ( await button . getText ( ) ) . toEqual ( 'Unique Delayed Button Text' )
42
42
} )
43
43
44
44
it ( 'findBy rejects when there is no matching element after timeout' , async ( ) => {
45
- const { findByText} = await setupBrowser ( browser )
45
+ const { findByText} = setupBrowser ( browser )
46
46
47
47
await expect ( findByText ( 'Text that does not exist' ) ) . rejects . toThrow ( )
48
48
} )
49
49
50
50
it ( 'findBy rejects when there are multiple matching elements' , async ( ) => {
51
- const { findByText} = await setupBrowser ( browser )
51
+ const { findByText} = setupBrowser ( browser )
52
52
53
53
await expect ( findByText ( 'Delayed Button Text' ) ) . rejects . toThrow ( )
54
54
} )
55
55
56
56
it ( 'queryAllBy resolves with matching elements' , async ( ) => {
57
- const { queryAllByText} = await setupBrowser ( browser )
57
+ const { queryAllByText} = setupBrowser ( browser )
58
58
59
59
const chans = await queryAllByText ( 'Button Text' )
60
60
expect ( chans ) . toHaveLength ( 2 )
61
61
} )
62
62
63
63
it ( 'queryAllBy resolves with an empty array when there are no matching elements' , async ( ) => {
64
- const { queryAllByText} = await setupBrowser ( browser )
64
+ const { queryAllByText} = setupBrowser ( browser )
65
65
66
66
const chans = await queryAllByText ( 'Text that does not exist' )
67
67
expect ( chans ) . toHaveLength ( 0 )
68
68
} )
69
69
70
70
it ( 'getAllBy resolves matching elements' , async ( ) => {
71
- const { getAllByText} = await setupBrowser ( browser )
71
+ const { getAllByText} = setupBrowser ( browser )
72
72
73
73
const buttons = await getAllByText ( 'Button Text' )
74
74
expect ( buttons ) . toHaveLength ( 2 )
75
75
} )
76
76
77
77
it ( 'getAllBy rejects when there are no matching elements' , async ( ) => {
78
- const { getAllByText} = await setupBrowser ( browser )
78
+ const { getAllByText} = setupBrowser ( browser )
79
79
80
80
await expect ( getAllByText ( 'Text that does not exist' ) ) . rejects . toThrow ( )
81
81
} )
82
82
83
83
it ( 'findAllBy waits for matching elements and resolves with them' , async ( ) => {
84
- const { findAllByText} = await setupBrowser ( browser )
84
+ const { findAllByText} = setupBrowser ( browser )
85
85
86
86
const buttons = await findAllByText ( 'Delayed Button Text' )
87
87
expect ( buttons ) . toHaveLength ( 2 )
88
88
} )
89
89
90
90
it ( 'findAllBy rejects when there are no matching elements after timeout' , async ( ) => {
91
- const { findAllByText} = await setupBrowser ( browser )
91
+ const { findAllByText} = setupBrowser ( browser )
92
92
93
93
await expect ( findAllByText ( 'Text that does not exist' ) ) . rejects . toThrow ( )
94
94
} )
95
95
96
96
it ( 'can click resolved elements' , async ( ) => {
97
- const { getByText, getAllByText} = await setupBrowser ( browser )
97
+ const { getByText, getAllByText} = setupBrowser ( browser )
98
98
99
99
const uniqueButton = await getByText ( 'Unique Button Text' )
100
100
const buttons = await getAllByText ( 'Button Text' )
@@ -109,29 +109,29 @@ describe('queries', () => {
109
109
} )
110
110
111
111
it ( 'support Regular Expressions' , async ( ) => {
112
- const { getAllByText} = await setupBrowser ( browser )
112
+ const { getAllByText} = setupBrowser ( browser )
113
113
114
114
const chans = await getAllByText ( / J a c k i e C h a n / )
115
115
expect ( chans ) . toHaveLength ( 2 )
116
116
} )
117
117
118
118
it ( 'support options' , async ( ) => {
119
- const { getAllByText} = await setupBrowser ( browser )
119
+ const { getAllByText} = setupBrowser ( browser )
120
120
121
121
const chans = await getAllByText ( 'Jackie Chan' , { exact : false } )
122
122
expect ( chans ) . toHaveLength ( 2 )
123
123
} )
124
124
125
125
it ( 'support waitFor options' , async ( ) => {
126
- const { findByText} = await setupBrowser ( browser )
126
+ const { findByText} = setupBrowser ( browser )
127
127
128
128
await expect (
129
129
findByText ( 'Unique Delayed Button Text' , { } , { timeout : 0 } ) ,
130
130
) . rejects . toThrow ( )
131
131
} )
132
132
133
133
it ( 'support being passed undefined arguments' , async ( ) => {
134
- const { findByText} = await setupBrowser ( browser )
134
+ const { findByText} = setupBrowser ( browser )
135
135
136
136
const button = await findByText (
137
137
'Unique Delayed Button Text' ,
@@ -142,7 +142,7 @@ describe('queries', () => {
142
142
} )
143
143
144
144
it ( 'retains error messages' , async ( ) => {
145
- const { getByText} = await setupBrowser ( browser )
145
+ const { getByText} = setupBrowser ( browser )
146
146
147
147
await expect ( getByText ( 'Text that does not exist' ) ) . rejects . toThrowError (
148
148
/ U n a b l e t o f i n d a n e l e m e n t w i t h t h e t e x t / ,
0 commit comments