File tree 1 file changed +42
-0
lines changed 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,45 @@ cases(
42
42
} ,
43
43
} ,
44
44
)
45
+
46
+ cases (
47
+ 'queryBy* queries throw an error when there are multiple elements returned' ,
48
+ ( { name, query, html} ) => {
49
+ const utils = render ( html )
50
+ expect ( ( ) => utils [ name ] ( query ) ) . toThrow ( / m u l t i p l e e l e m e n t s / i)
51
+ } ,
52
+ {
53
+ queryByLabelText : {
54
+ query : / h i s / ,
55
+ html : `<div aria-label="his"></div><div aria-label="history"></div>` ,
56
+ } ,
57
+ queryByPlaceholderText : {
58
+ query : / h i s / ,
59
+ html : `<input placeholder="his" /><input placeholder="history" />` ,
60
+ } ,
61
+ queryByText : {
62
+ query : / h i s / ,
63
+ html : `<div>his</div><div>history</div>` ,
64
+ } ,
65
+ queryByAltText : {
66
+ query : / h i s / ,
67
+ html : `<img alt="his" src="his.png" /><img alt="history" src="history.png" />` ,
68
+ } ,
69
+ queryByTitle : {
70
+ query : / h i s / ,
71
+ html : `<div title="his"></div><div title="history"></div>` ,
72
+ } ,
73
+ queryByDisplayValue : {
74
+ query : / h i s / ,
75
+ html : `<input value="his" /><select><option value="history">history</option></select>` ,
76
+ } ,
77
+ queryByRole : {
78
+ query : / h i s / ,
79
+ html : `<div role="his"></div><div role="history"></div>` ,
80
+ } ,
81
+ queryByTestId : {
82
+ query : / h i s / ,
83
+ html : `<div data-testid="his"></div><div data-testid="history"></div>` ,
84
+ } ,
85
+ } ,
86
+ )
You can’t perform that action at this time.
0 commit comments