@gtkx/testing 2.0.0-beta.11 → 2.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +3 -3
  2. package/dist/accessible-native.d.ts.map +1 -1
  3. package/dist/accessible-native.js.map +1 -1
  4. package/dist/act.d.ts.map +1 -1
  5. package/dist/build-queries.d.ts +1 -1
  6. package/dist/build-queries.d.ts.map +1 -1
  7. package/dist/build-queries.js +1 -1
  8. package/dist/build-queries.js.map +1 -1
  9. package/dist/cleanup-registry.d.ts.map +1 -1
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/editable.d.ts.map +1 -1
  12. package/dist/errors.d.ts.map +1 -1
  13. package/dist/errors.js.map +1 -1
  14. package/dist/fire-event.d.ts.map +1 -1
  15. package/dist/fire-event.js +5 -2
  16. package/dist/fire-event.js.map +1 -1
  17. package/dist/frame-sync.d.ts.map +1 -1
  18. package/dist/frame-sync.js +1 -10
  19. package/dist/frame-sync.js.map +1 -1
  20. package/dist/harness-window.d.ts.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/matchers.d.ts.map +1 -1
  26. package/dist/matchers.js.map +1 -1
  27. package/dist/normalize.d.ts +1 -1
  28. package/dist/normalize.d.ts.map +1 -1
  29. package/dist/normalize.js +1 -1
  30. package/dist/normalize.js.map +1 -1
  31. package/dist/pretty-widget.d.ts.map +1 -1
  32. package/dist/pretty-widget.js.map +1 -1
  33. package/dist/production.d.ts.map +1 -1
  34. package/dist/queries.d.ts.map +1 -1
  35. package/dist/queries.js +3 -5
  36. package/dist/queries.js.map +1 -1
  37. package/dist/render-hook.js.map +1 -1
  38. package/dist/render.d.ts.map +1 -1
  39. package/dist/render.js.map +1 -1
  40. package/dist/role-helpers.d.ts.map +1 -1
  41. package/dist/role-naming.d.ts.map +1 -1
  42. package/dist/screen.d.ts.map +1 -1
  43. package/dist/screenshot.d.ts.map +1 -1
  44. package/dist/screenshot.js.map +1 -1
  45. package/dist/suggestions.d.ts +1 -1
  46. package/dist/suggestions.d.ts.map +1 -1
  47. package/dist/suggestions.js +1 -1
  48. package/dist/suggestions.js.map +1 -1
  49. package/dist/timers.d.ts.map +1 -1
  50. package/dist/traversal.d.ts.map +1 -1
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/types.js.map +1 -1
  53. package/dist/user-event/adjustment.d.ts.map +1 -1
  54. package/dist/user-event/adjustment.js.map +1 -1
  55. package/dist/user-event/click.d.ts.map +1 -1
  56. package/dist/user-event/click.js +0 -1
  57. package/dist/user-event/click.js.map +1 -1
  58. package/dist/user-event/column-header-click.d.ts.map +1 -1
  59. package/dist/user-event/column-header-click.js +1 -1
  60. package/dist/user-event/column-header-click.js.map +1 -1
  61. package/dist/user-event/controller.d.ts +1 -1
  62. package/dist/user-event/controller.d.ts.map +1 -1
  63. package/dist/user-event/controller.js +1 -1
  64. package/dist/user-event/controller.js.map +1 -1
  65. package/dist/user-event/dispatch.d.ts.map +1 -1
  66. package/dist/user-event/event-wrapper.d.ts.map +1 -1
  67. package/dist/user-event/event-wrapper.js.map +1 -1
  68. package/dist/user-event/gesture.d.ts.map +1 -1
  69. package/dist/user-event/gesture.js +4 -3
  70. package/dist/user-event/gesture.js.map +1 -1
  71. package/dist/user-event/index.d.ts.map +1 -1
  72. package/dist/user-event/index.js +1 -1
  73. package/dist/user-event/index.js.map +1 -1
  74. package/dist/user-event/indexed-children.d.ts.map +1 -1
  75. package/dist/user-event/keyboard.d.ts.map +1 -1
  76. package/dist/user-event/keyboard.js +40 -14
  77. package/dist/user-event/keyboard.js.map +1 -1
  78. package/dist/user-event/list-row-click.d.ts.map +1 -1
  79. package/dist/user-event/native-click.d.ts.map +1 -1
  80. package/dist/user-event/native-click.js +1 -3
  81. package/dist/user-event/native-click.js.map +1 -1
  82. package/dist/user-event/notebook-tab-click.d.ts.map +1 -1
  83. package/dist/user-event/notebook-tab-click.js +1 -1
  84. package/dist/user-event/notebook-tab-click.js.map +1 -1
  85. package/dist/user-event/pointer.d.ts.map +1 -1
  86. package/dist/user-event/selection.d.ts.map +1 -1
  87. package/dist/user-event/selection.js.map +1 -1
  88. package/dist/user-event/text.d.ts.map +1 -1
  89. package/dist/user-event/text.js.map +1 -1
  90. package/dist/wait-for.d.ts.map +1 -1
  91. package/dist/wait-for.js.map +1 -1
  92. package/dist/widget-accessible-properties.d.ts.map +1 -1
  93. package/dist/widget-accessible-properties.js +3 -4
  94. package/dist/widget-accessible-properties.js.map +1 -1
  95. package/dist/widget-getters.d.ts.map +1 -1
  96. package/dist/widget-getters.js +0 -1
  97. package/dist/widget-getters.js.map +1 -1
  98. package/dist/widget-target.d.ts.map +1 -1
  99. package/dist/window-state.d.ts.map +1 -1
  100. package/dist/window-state.js +3 -1
  101. package/dist/window-state.js.map +1 -1
  102. package/dist/within.d.ts.map +1 -1
  103. package/dist/within.js.map +1 -1
  104. package/package.json +12 -19
  105. package/src/accessible-native.ts +2 -2
  106. package/src/build-queries.ts +52 -70
  107. package/src/errors.ts +6 -6
  108. package/src/fire-event.ts +6 -7
  109. package/src/frame-sync.ts +1 -13
  110. package/src/index.ts +2 -12
  111. package/src/matchers.ts +28 -34
  112. package/src/normalize.ts +1 -4
  113. package/src/queries.ts +8 -20
  114. package/src/render-hook.tsx +1 -1
  115. package/src/render.tsx +1 -1
  116. package/src/screenshot.ts +3 -8
  117. package/src/suggestions.ts +1 -1
  118. package/src/types.ts +11 -15
  119. package/src/user-event/adjustment.ts +1 -3
  120. package/src/user-event/click.ts +2 -9
  121. package/src/user-event/column-header-click.ts +1 -1
  122. package/src/user-event/controller.ts +1 -1
  123. package/src/user-event/event-wrapper.ts +1 -1
  124. package/src/user-event/gesture.ts +7 -7
  125. package/src/user-event/index.ts +10 -22
  126. package/src/user-event/keyboard.ts +58 -17
  127. package/src/user-event/native-click.ts +1 -3
  128. package/src/user-event/notebook-tab-click.ts +1 -1
  129. package/src/user-event/selection.ts +3 -12
  130. package/src/user-event/text.ts +3 -6
  131. package/src/wait-for.ts +1 -4
  132. package/src/widget-accessible-properties.ts +6 -8
  133. package/src/widget-getters.ts +1 -3
  134. package/src/window-state.ts +4 -3
  135. package/src/within.ts +2 -2
@@ -12,19 +12,13 @@ import { requireWidget } from "./widget-target.js";
12
12
  * family's own matcher arguments. Its name determines the family name, so `queryAllByTestId` builds
13
13
  * a `TestId` family.
14
14
  */
15
- type QueryAllBy<
16
- Args extends unknown[],
17
- Element extends Gtk.Accessible = Gtk.Accessible,
18
- > = (
15
+ type QueryAllBy<Args extends unknown[], Element extends Gtk.Accessible = Gtk.Accessible> = (
19
16
  container: Container,
20
17
  ...args: Args
21
18
  ) => Element[];
22
19
 
23
20
  /** Builds the error thrown when a single-match query finds more than one widget. */
24
- type MultipleErrorBuilder<
25
- Args extends unknown[],
26
- Element extends Gtk.Accessible = Gtk.Accessible,
27
- > = (
21
+ type MultipleErrorBuilder<Args extends unknown[], Element extends Gtk.Accessible = Gtk.Accessible> = (
28
22
  container: Container,
29
23
  matches: Element[],
30
24
  ...args: Args
@@ -34,10 +28,7 @@ type MultipleErrorBuilder<
34
28
  type MissingErrorBuilder<Args extends unknown[]> = (container: Container, ...args: Args) => Error;
35
29
 
36
30
  /** The variants derived from one `queryAllBy` function, in the order DOM Testing Library returns them. */
37
- type BuiltQueries<
38
- Args extends unknown[],
39
- Element extends Gtk.Accessible = Gtk.Accessible,
40
- > = [
31
+ type BuiltQueries<Args extends unknown[], Element extends Gtk.Accessible = Gtk.Accessible> = [
41
32
  queryBy: (container: Container, ...args: Args) => Element | null,
42
33
  getAllBy: QueryAllBy<Args, Element>,
43
34
  getBy: (container: Container, ...args: Args) => Element,
@@ -127,30 +118,30 @@ const singleFrom =
127
118
  allQuery: QueryAllBy<Args, Element>,
128
119
  getMultipleError: MultipleErrorBuilder<Args, Element>,
129
120
  ): SingleQuery<Args, Element> =>
130
- (container, ...args) => {
131
- const matches = allQuery(container, ...args);
121
+ (container, ...args) => {
122
+ const matches = allQuery(container, ...args);
132
123
 
133
- if (matches.length > 1) {
134
- throw getMultipleError(container, matches, ...args);
135
- }
124
+ if (matches.length > 1) {
125
+ throw getMultipleError(container, matches, ...args);
126
+ }
136
127
 
137
- return matches[0] ?? null;
138
- };
128
+ return matches[0] ?? null;
129
+ };
139
130
 
140
131
  const allOrThrow =
141
132
  <Args extends unknown[], Element extends Gtk.Accessible>(
142
133
  allQuery: QueryAllBy<Args, Element>,
143
134
  getMissingError: MissingErrorBuilder<Args>,
144
135
  ): QueryAllBy<Args, Element> =>
145
- (container, ...args) => {
146
- const matches = allQuery(container, ...args);
136
+ (container, ...args) => {
137
+ const matches = allQuery(container, ...args);
147
138
 
148
- if (matches.length === 0) {
149
- throw getMissingError(container, ...args);
150
- }
139
+ if (matches.length === 0) {
140
+ throw getMissingError(container, ...args);
141
+ }
151
142
 
152
- return matches;
153
- };
143
+ return matches;
144
+ };
154
145
 
155
146
  const wrapSingleWithSuggestion =
156
147
  <Args extends unknown[], Element extends Gtk.Accessible>(
@@ -158,55 +149,55 @@ const wrapSingleWithSuggestion =
158
149
  queryName: string,
159
150
  variant: Variant,
160
151
  ): SingleQuery<Args, Element> =>
161
- (container, ...args) => {
162
- const match = query(container, ...args);
163
-
164
- if (match) {
165
- maybeThrowSuggestion({
166
- container,
167
- matches: [match],
168
- queryName,
169
- variant,
170
- shouldSuggest: extractShouldSuggest(args),
171
- });
172
- }
173
-
174
- return match;
175
- };
152
+ (container, ...args) => {
153
+ const match = query(container, ...args);
176
154
 
177
- const wrapAllWithSuggestion =
178
- <Args extends unknown[], Element extends Gtk.Accessible>(
179
- query: QueryAllBy<Args, Element>,
180
- queryName: string,
181
- variant: Variant,
182
- ): QueryAllBy<Args, Element> =>
183
- (container, ...args) => {
184
- const matches = query(container, ...args);
155
+ if (match) {
185
156
  maybeThrowSuggestion({
186
157
  container,
187
- matches,
158
+ matches: [match],
188
159
  queryName,
189
160
  variant,
190
161
  shouldSuggest: extractShouldSuggest(args),
191
162
  });
163
+ }
192
164
 
193
- return matches;
194
- };
165
+ return match;
166
+ };
167
+
168
+ const wrapAllWithSuggestion =
169
+ <Args extends unknown[], Element extends Gtk.Accessible>(
170
+ query: QueryAllBy<Args, Element>,
171
+ queryName: string,
172
+ variant: Variant,
173
+ ): QueryAllBy<Args, Element> =>
174
+ (container, ...args) => {
175
+ const matches = query(container, ...args);
176
+ maybeThrowSuggestion({
177
+ container,
178
+ matches,
179
+ queryName,
180
+ variant,
181
+ shouldSuggest: extractShouldSuggest(args),
182
+ });
183
+
184
+ return matches;
185
+ };
195
186
 
196
187
  const requireSingle =
197
188
  <Args extends unknown[], Element extends Gtk.Accessible>(
198
189
  query: SingleQuery<Args, Element>,
199
190
  getMissingError: MissingErrorBuilder<Args>,
200
191
  ) =>
201
- (container: Container, ...args: Args): Element => {
202
- const match = query(container, ...args);
192
+ (container: Container, ...args: Args): Element => {
193
+ const match = query(container, ...args);
203
194
 
204
- if (match === null) {
205
- throw getMissingError(container, ...args);
206
- }
195
+ if (match === null) {
196
+ throw getMissingError(container, ...args);
197
+ }
207
198
 
208
- return match;
209
- };
199
+ return match;
200
+ };
210
201
 
211
202
  /**
212
203
  * Builds a query family from `queryAllBy`, following DOM Testing Library's `buildQueries`.
@@ -217,10 +208,7 @@ const requireSingle =
217
208
  * @param getMissingError Builds errors for required queries finding no widgets.
218
209
  * @returns `[queryBy, getAllBy, getBy, findAllBy, findBy]`.
219
210
  */
220
- const buildQueries = <
221
- Args extends unknown[],
222
- Element extends Gtk.Accessible = Gtk.Accessible,
223
- >(
211
+ const buildQueries = <Args extends unknown[], Element extends Gtk.Accessible = Gtk.Accessible>(
224
212
  queryAllBy: QueryAllBy<Args, Element>,
225
213
  getMultipleError: MultipleErrorBuilder<Args, Element>,
226
214
  getMissingError: MissingErrorBuilder<Args>,
@@ -266,10 +254,4 @@ const buildQueries = <
266
254
  return [queryByWithSuggestion, getAllByWithSuggestion, getByWithSuggestion, findAllBy, findBy];
267
255
  };
268
256
 
269
- export {
270
- buildQueries,
271
- type BuiltQueries,
272
- type MissingErrorBuilder,
273
- type MultipleErrorBuilder,
274
- type QueryAllBy,
275
- };
257
+ export { buildQueries, type BuiltQueries, type MissingErrorBuilder, type MultipleErrorBuilder, type QueryAllBy };
package/src/errors.ts CHANGED
@@ -6,12 +6,12 @@ import { prettyWidget } from "./pretty-widget.js";
6
6
  import { formatRole, prettyRoles } from "./role-helpers.js";
7
7
 
8
8
  type QueryDescriptor =
9
- | { queryType: "role"; role: Gtk.AccessibleRole; options?: ByRoleOptions | undefined } |
10
- { queryType: "text"; text: Matcher } |
11
- { queryType: "labelText"; text: Matcher } |
12
- { queryType: "name"; name: Matcher } |
13
- { queryType: "placeholderText"; text: Matcher } |
14
- { queryType: "displayValue"; value: Matcher };
9
+ | { queryType: "role"; role: Gtk.AccessibleRole; options?: ByRoleOptions | undefined }
10
+ | { queryType: "text"; text: Matcher }
11
+ | { queryType: "labelText"; text: Matcher }
12
+ | { queryType: "name"; name: Matcher }
13
+ | { queryType: "placeholderText"; text: Matcher }
14
+ | { queryType: "displayValue"; value: Matcher };
15
15
 
16
16
  const roleOptionFormatters: ((options: ByRoleOptions) => string | null)[] = [
17
17
  (o) => (o.name ? `name ${formatTextMatcher(o.name)}` : null),
package/src/fire-event.ts CHANGED
@@ -50,8 +50,11 @@ const dispatchEvent = async (event: WidgetEvent): Promise<void> => {
50
50
  };
51
51
 
52
52
  const isWidgetEvent = (value: object): value is WidgetEvent =>
53
- "target" in value && "signalName" in value && "args" in value &&
54
- typeof value.signalName === "string" && Array.isArray(value.args);
53
+ "target" in value &&
54
+ "signalName" in value &&
55
+ "args" in value &&
56
+ typeof value.signalName === "string" &&
57
+ Array.isArray(value.args);
55
58
 
56
59
  /**
57
60
  * Emits a recorded signal emission inside React's act environment, so any resulting state updates are
@@ -68,11 +71,7 @@ function fireEvent(event: WidgetEvent): Promise<void>;
68
71
  * @param signalName Name of the signal to emit.
69
72
  * @param args Arguments passed to the signal handlers.
70
73
  */
71
- function fireEvent(
72
- target: Pick<GObject.Object, "__type__">,
73
- signalName: string,
74
- ...args: unknown[]
75
- ): Promise<void>;
74
+ function fireEvent(target: Pick<GObject.Object, "__type__">, signalName: string, ...args: unknown[]): Promise<void>;
76
75
 
77
76
  function fireEvent(
78
77
  eventOrTarget: WidgetEvent | Pick<GObject.Object, "__type__">,
package/src/frame-sync.ts CHANGED
@@ -1,22 +1,10 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
2
  import * as GLib from "@gtkx/gi/glib";
3
+ import { once } from "@gtkx/utils";
3
4
  import { cancelTimeout, scheduleTimeout } from "./timers.js";
4
5
 
5
6
  const CLOCK_STALL_FALLBACK_MS = 500;
6
7
 
7
- const once = (callback: () => void): (() => void) => {
8
- let isCalled = false;
9
-
10
- return () => {
11
- if (isCalled) {
12
- return;
13
- }
14
-
15
- isCalled = true;
16
- callback();
17
- };
18
- };
19
-
20
8
  const hasFrameClock = (widget: Gtk.Widget | null): widget is Gtk.Widget => widget?.getFrameClock() != null;
21
9
 
22
10
  const runUntilReady = (widget: Gtk.Widget, isReady: () => boolean, timeout: number, finish: () => void): void => {
package/src/index.ts CHANGED
@@ -2,12 +2,7 @@ import "./register-test-hooks.js";
2
2
 
3
3
  export { act } from "./act.js";
4
4
  export type { BoundQueries, RenderResult, Screen } from "./bound-queries.js";
5
- export type {
6
- BuiltQueries,
7
- MissingErrorBuilder,
8
- MultipleErrorBuilder,
9
- QueryAllBy,
10
- } from "./build-queries.js";
5
+ export type { BuiltQueries, MissingErrorBuilder, MultipleErrorBuilder, QueryAllBy } from "./build-queries.js";
11
6
  export { buildQueries } from "./build-queries.js";
12
7
  export type { Config, ConfigFn } from "./config.js";
13
8
  export { configure, getConfig } from "./config.js";
@@ -86,12 +81,7 @@ export type {
86
81
  WrapperComponent,
87
82
  } from "./types.js";
88
83
  export type { ControllerConstructor } from "./user-event/controller.js";
89
- export {
90
- getAllControllers,
91
- getController,
92
- queryAllControllers,
93
- queryController,
94
- } from "./user-event/controller.js";
84
+ export { getAllControllers, getController, queryAllControllers, queryController } from "./user-event/controller.js";
95
85
  export type {
96
86
  DragOffset,
97
87
  DragOptions,
package/src/matchers.ts CHANGED
@@ -80,37 +80,37 @@ type ClassArguments = { expected: ClassExpectation[]; isExact: boolean };
80
80
  type QueryAll<Args extends unknown[]> = (container: Container, ...args: Args) => object[];
81
81
 
82
82
  type BooleanAccessibleState =
83
- Gtk.AccessibleState.BUSY |
84
- Gtk.AccessibleState.DISABLED |
85
- Gtk.AccessibleState.EXPANDED |
86
- Gtk.AccessibleState.HIDDEN |
87
- Gtk.AccessibleState.SELECTED |
88
- Gtk.AccessibleState.VISITED;
83
+ | Gtk.AccessibleState.BUSY
84
+ | Gtk.AccessibleState.DISABLED
85
+ | Gtk.AccessibleState.EXPANDED
86
+ | Gtk.AccessibleState.HIDDEN
87
+ | Gtk.AccessibleState.SELECTED
88
+ | Gtk.AccessibleState.VISITED;
89
89
 
90
90
  type TristateAccessibleState = Gtk.AccessibleState.CHECKED | Gtk.AccessibleState.PRESSED;
91
91
 
92
92
  type StringAccessibleProperty =
93
- Gtk.AccessibleProperty.DESCRIPTION |
94
- Gtk.AccessibleProperty.HELP_TEXT |
95
- Gtk.AccessibleProperty.KEY_SHORTCUTS |
96
- Gtk.AccessibleProperty.LABEL |
97
- Gtk.AccessibleProperty.PLACEHOLDER |
98
- Gtk.AccessibleProperty.ROLE_DESCRIPTION |
99
- Gtk.AccessibleProperty.VALUE_TEXT;
93
+ | Gtk.AccessibleProperty.DESCRIPTION
94
+ | Gtk.AccessibleProperty.HELP_TEXT
95
+ | Gtk.AccessibleProperty.KEY_SHORTCUTS
96
+ | Gtk.AccessibleProperty.LABEL
97
+ | Gtk.AccessibleProperty.PLACEHOLDER
98
+ | Gtk.AccessibleProperty.ROLE_DESCRIPTION
99
+ | Gtk.AccessibleProperty.VALUE_TEXT;
100
100
 
101
101
  type BooleanAccessibleProperty =
102
- Gtk.AccessibleProperty.HAS_POPUP |
103
- Gtk.AccessibleProperty.MODAL |
104
- Gtk.AccessibleProperty.MULTI_LINE |
105
- Gtk.AccessibleProperty.MULTI_SELECTABLE |
106
- Gtk.AccessibleProperty.READ_ONLY |
107
- Gtk.AccessibleProperty.REQUIRED;
102
+ | Gtk.AccessibleProperty.HAS_POPUP
103
+ | Gtk.AccessibleProperty.MODAL
104
+ | Gtk.AccessibleProperty.MULTI_LINE
105
+ | Gtk.AccessibleProperty.MULTI_SELECTABLE
106
+ | Gtk.AccessibleProperty.READ_ONLY
107
+ | Gtk.AccessibleProperty.REQUIRED;
108
108
 
109
109
  type NumberAccessibleProperty =
110
- Gtk.AccessibleProperty.LEVEL |
111
- Gtk.AccessibleProperty.VALUE_MAX |
112
- Gtk.AccessibleProperty.VALUE_MIN |
113
- Gtk.AccessibleProperty.VALUE_NOW;
110
+ | Gtk.AccessibleProperty.LEVEL
111
+ | Gtk.AccessibleProperty.VALUE_MAX
112
+ | Gtk.AccessibleProperty.VALUE_MIN
113
+ | Gtk.AccessibleProperty.VALUE_NOW;
114
114
 
115
115
  /** A text matcher that also takes normalization options for the text it reads. */
116
116
  type TextContentMatcher = (
@@ -650,11 +650,7 @@ function readTextContent(widget: Gtk.Widget, options?: TextContentOptions): stri
650
650
  return text === null ? null : normalizeTextContent(text, options);
651
651
  }
652
652
 
653
- function toHaveTextContent(
654
- received: unknown,
655
- expected?: TextExpectation,
656
- options?: TextContentOptions,
657
- ): MatcherResult {
653
+ function toHaveTextContent(received: unknown, expected?: TextExpectation, options?: TextContentOptions): MatcherResult {
658
654
  const read = (widget: Gtk.Widget): string | null => readTextContent(widget, options);
659
655
 
660
656
  return textMatcher("toHaveTextContent", read, "substring")(received, expected);
@@ -663,7 +659,7 @@ function toHaveTextContent(
663
659
  function notApplicable(matcherName: string, stateName: string, widget: Gtk.Widget): Error {
664
660
  return new Error(
665
661
  `${matcherName}: widget does not expose a ${stateName} ` +
666
- `(role ${Gtk.AccessibleRole[widget.getAccessibleRole()]})\n${describeWidget(widget)}`,
662
+ `(role ${Gtk.AccessibleRole[widget.getAccessibleRole()]})\n${describeWidget(widget)}`,
667
663
  );
668
664
  }
669
665
 
@@ -999,8 +995,8 @@ const registerMatchers = (): void => {
999
995
  };
1000
996
 
1001
997
  declare module "vitest" {
1002
- /* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-unused-vars --
1003
- declaration merging requires an interface with vitest's exact type parameters */
998
+ /* eslint-disable @typescript-eslint/no-unused-vars --
999
+ declaration merging requires vitest's exact type parameters */
1004
1000
  interface Matchers<R extends void | Promise<void> = void | Promise<void>, T = unknown> {
1005
1001
  toHaveDisplayValue(expected?: TextExpectation): R;
1006
1002
  toHaveTextContent(expected?: TextExpectation, options?: TextContentOptions): R;
@@ -1008,12 +1004,10 @@ declare module "vitest" {
1008
1004
  toHaveAccessibleDescription(expected?: TextExpectation): R;
1009
1005
  toHaveAccessibleErrorMessage(expected?: TextExpectation): R;
1010
1006
  toHaveSelection(expected?: TextExpectation): R;
1011
- /* eslint-disable-next-line unicorn/consistent-boolean-name -- expected is the jest-dom matcher argument name */
1012
1007
  toHaveAccessibleState(state: BooleanAccessibleState, expected?: boolean): R;
1013
1008
  toHaveAccessibleState(state: TristateAccessibleState, expected?: Gtk.AccessibleTristate): R;
1014
1009
  toHaveAccessibleState(state: Gtk.AccessibleState.INVALID, expected?: Gtk.AccessibleInvalidState): R;
1015
1010
  toHaveAccessibleProperty(property: StringAccessibleProperty, expected?: string): R;
1016
- /* eslint-disable-next-line unicorn/consistent-boolean-name -- expected is the jest-dom matcher argument name */
1017
1011
  toHaveAccessibleProperty(property: BooleanAccessibleProperty, expected?: boolean): R;
1018
1012
  toHaveAccessibleProperty(property: NumberAccessibleProperty, expected?: number): R;
1019
1013
  toHaveAccessibleProperty(
@@ -1053,7 +1047,7 @@ declare module "vitest" {
1053
1047
  toHaveClass(...args: (ClassExpectation | { exact: boolean })[]): R;
1054
1048
  toHaveObjectProperty(name: string, expected?: unknown): R;
1055
1049
  }
1056
- /* eslint-enable @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-unused-vars */
1050
+ /* eslint-enable @typescript-eslint/no-unused-vars */
1057
1051
  }
1058
1052
 
1059
1053
  export { matchers, registerMatchers, type ClassExpectation, type TextContentOptions, type TextExpectation };
package/src/normalize.ts CHANGED
@@ -6,10 +6,7 @@ import type { NormalizerFn, NormalizerOptions } from "./types.js";
6
6
  * @param options Toggles for trimming and whitespace collapsing.
7
7
  * @returns A function that normalizes a string for comparison against a matcher.
8
8
  */
9
- const getDefaultNormalizer = ({
10
- trim = true,
11
- collapseWhitespace = true,
12
- }: NormalizerOptions = {}): NormalizerFn => {
9
+ const getDefaultNormalizer = ({ trim = true, collapseWhitespace = true }: NormalizerOptions = {}): NormalizerFn => {
13
10
  return (text: string): string => {
14
11
  let result = text;
15
12
 
package/src/queries.ts CHANGED
@@ -1,12 +1,5 @@
1
1
  import * as Gtk from "@gtkx/gi/gtk";
2
- import type {
3
- ByRoleOptions,
4
- ByRoleValue,
5
- Matcher,
6
- MatcherOptions,
7
- NormalizerFn,
8
- QueryFamilies,
9
- } from "./types.js";
2
+ import type { ByRoleOptions, ByRoleValue, Matcher, MatcherOptions, NormalizerFn, QueryFamilies } from "./types.js";
10
3
  import { buildQueries, type BuiltQueries, type QueryAllBy } from "./build-queries.js";
11
4
  import { multipleFoundError, notFoundError } from "./errors.js";
12
5
  import { getDefaultNormalizer } from "./normalize.js";
@@ -177,8 +170,8 @@ const buildNormalizer = (options?: MatcherOptions): NormalizerFn => {
177
170
  if (trim !== undefined || collapseWhitespace !== undefined) {
178
171
  throw new Error(
179
172
  "trim and collapseWhitespace are not supported with a normalizer. " +
180
- "If you want to use the default trim and collapseWhitespace logic in your normalizer, " +
181
- "use \"getDefaultNormalizer({ trim, collapseWhitespace })\" and compose that into your normalizer",
173
+ "If you want to use the default trim and collapseWhitespace logic in your normalizer, " +
174
+ 'use "getDefaultNormalizer({ trim, collapseWhitespace })" and compose that into your normalizer',
182
175
  );
183
176
  }
184
177
 
@@ -287,18 +280,14 @@ const hasMatchingAccessibleStates = (widget: Gtk.Widget, options: ByRoleOptions)
287
280
  const isMatchingWidgetType = <T extends Gtk.Accessible>(
288
281
  widget: Gtk.Widget,
289
282
  options?: MatcherOptions<T>,
290
- ): widget is Gtk.Widget & T =>
291
- options?.as === undefined || widget instanceof options.as;
283
+ ): widget is Gtk.Widget & T => options?.as === undefined || widget instanceof options.as;
292
284
 
293
285
  const hasMatchingAccessibleOptions = (widget: Gtk.Widget, options?: ByRoleOptions): boolean => {
294
286
  if (!options) {
295
287
  return true;
296
288
  }
297
289
 
298
- return (
299
- hasMatchingAccessibleName(widget, options) &&
300
- hasMatchingAccessibleStates(widget, options)
301
- );
290
+ return hasMatchingAccessibleName(widget, options) && hasMatchingAccessibleStates(widget, options);
302
291
  };
303
292
 
304
293
  function nameQueryFamily<Args extends unknown[], Element extends Gtk.Accessible>(
@@ -416,8 +405,8 @@ function queryAllByLabelText<T extends Gtk.Accessible = Gtk.Widget>(
416
405
  collectLabelMatches(results, widget, text, options);
417
406
  }
418
407
 
419
- return [...results].filter((widget): widget is Gtk.Widget & T =>
420
- widgets.has(widget) && isMatchingWidgetType(widget, options),
408
+ return [...results].filter(
409
+ (widget): widget is Gtk.Widget & T => widgets.has(widget) && isMatchingWidgetType(widget, options),
421
410
  );
422
411
  }
423
412
 
@@ -499,8 +488,7 @@ function queryAllByDisplayValue<T extends Gtk.Accessible = Gtk.Widget>(
499
488
  const matches = findAll(
500
489
  container,
501
490
  (widget) =>
502
- isMatchingWidgetType(widget, options) &&
503
- isTextMatch(getWidgetDisplayValue(widget), value, widget, options),
491
+ isMatchingWidgetType(widget, options) && isTextMatch(getWidgetDisplayValue(widget), value, widget, options),
504
492
  );
505
493
 
506
494
  return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));
@@ -32,7 +32,7 @@ async function renderHook<Result, Props>(
32
32
  callback: (props: Props) => Result,
33
33
  options?: RenderHookOptions<Props>,
34
34
  ): Promise<RenderHookResult<Result, Props>> {
35
- const initialProps = (options as { initialProps?: Props } | undefined)?.initialProps as Props;
35
+ const initialProps = options?.initialProps as Props;
36
36
  const resultRef: { current: Result | undefined } = { current: undefined };
37
37
  let currentProps: Props = initialProps;
38
38
 
package/src/render.tsx CHANGED
@@ -61,7 +61,7 @@ const settleWindow = async (
61
61
  if (failure !== null) {
62
62
  throw new Error(
63
63
  `${action} timed out after ${String(timeout)}ms waiting for the window it rendered into: ${failure}. ` +
64
- "Platform state such as focus is only readable once that window is allocated and active.",
64
+ "Platform state such as focus is only readable once that window is allocated and active.",
65
65
  );
66
66
  }
67
67
  };
package/src/screenshot.ts CHANGED
@@ -24,13 +24,9 @@ type CaptureState = {
24
24
  failure: CaptureFailure | null;
25
25
  };
26
26
 
27
- type CaptureResult =
28
- { status: "captured"; result: ScreenshotResult } |
29
- { status: "failed"; failure: CaptureFailure };
27
+ type CaptureResult = { status: "captured"; result: ScreenshotResult } | { status: "failed"; failure: CaptureFailure };
30
28
 
31
- type CaptureOutcome =
32
- { status: "captured"; result: ScreenshotResult } |
33
- { status: "stalled"; failure: CaptureFailure };
29
+ type CaptureOutcome = { status: "captured"; result: ScreenshotResult } | { status: "stalled"; failure: CaptureFailure };
34
30
 
35
31
  type BackgroundSnapshot = {
36
32
  renderBackground(...args: [context: object, x: number, y: number, width: number, height: number]): void;
@@ -57,8 +53,7 @@ const NOT_PRESENTING_MESSAGE =
57
53
  const EMPTY_WIDGET_HINT =
58
54
  "The display is presenting frames to this window, so the widget itself is empty: it painted nothing.";
59
55
 
60
- const OTHER_FAILURE_HINT =
61
- "The display is presenting frames to this window, so the capture failed for another reason.";
56
+ const OTHER_FAILURE_HINT = "The display is presenting frames to this window, so the capture failed for another reason.";
62
57
 
63
58
  const NOTHING_ON_SCREEN_MESSAGE = "Nothing is on screen to capture: no toplevel window is mapped";
64
59
 
@@ -70,7 +70,7 @@ const textSuggestion = (queryName: Method, variant: Variant, value: string | nul
70
70
  /**
71
71
  * Computes the recommended query for reaching the given widget, preferring role, then label text,
72
72
  * placeholder text, text, display value, and name.
73
- * @param widget Widget to build a suggestion for.
73
+ * @param target Widget to build a suggestion for.
74
74
  * @param variant Query variant the suggestion should use.
75
75
  * @param method Restrict the suggestion to a specific query family instead of choosing by priority.
76
76
  * @returns The best available suggestion, or undefined when no query applies.
package/src/types.ts CHANGED
@@ -17,9 +17,7 @@ type NormalizerFn = (text: string) => string;
17
17
  * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and
18
18
  * generated GInterface pseudo-classes that extend `Gtk.Accessible` are accepted.
19
19
  */
20
- type WidgetType<T extends Gtk.Accessible = Gtk.Accessible> = abstract new (
21
- ...args: never[]
22
- ) => T;
20
+ type WidgetType<T extends Gtk.Accessible = Gtk.Accessible> = abstract new (...args: never[]) => T;
23
21
 
24
22
  /** Options controlling the default text normalizer. */
25
23
  type NormalizerOptions = {
@@ -138,19 +136,17 @@ type QueryKind = "role" | "text" | "name" | "value";
138
136
  type QueryArgs<Kind extends QueryKind, T extends Gtk.Accessible> = Kind extends "role"
139
137
  ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]
140
138
  : Kind extends "name"
141
- ? [name: Matcher, options?: MatcherOptions<T>]
142
- : Kind extends "value"
143
- ? [value: Matcher, options?: MatcherOptions<T>]
144
- : [text: Matcher, options?: MatcherOptions<T>];
139
+ ? [name: Matcher, options?: MatcherOptions<T>]
140
+ : Kind extends "value"
141
+ ? [value: Matcher, options?: MatcherOptions<T>]
142
+ : [text: Matcher, options?: MatcherOptions<T>];
145
143
 
146
144
  /**
147
145
  * One family's query variants, each named for its variant followed by `Suffix` and taking `Head`
148
146
  * ahead of the family's own arguments.
149
147
  */
150
148
  type QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {
151
- [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <
152
- T extends Gtk.Accessible = Gtk.Widget,
153
- >(
149
+ [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Accessible = Gtk.Widget>(
154
150
  ...args: [...Head, ...QueryArgs<Kind, T>]
155
151
  ) => QueryFamilyReturns<T>[K];
156
152
  };
@@ -239,12 +235,12 @@ type RenderHookOptions<Props> = {
239
235
  wrapper?: WrapperComponent;
240
236
  } & (undefined extends Props
241
237
  ? {
242
- /** Props the hook is invoked with until `rerender` is given new ones. */
243
- initialProps?: Props;
244
- }
238
+ /** Props the hook is invoked with until `rerender` is given new ones. */
239
+ initialProps?: Props;
240
+ }
245
241
  : {
246
- initialProps: Props;
247
- });
242
+ initialProps: Props;
243
+ });
248
244
 
249
245
  /**
250
246
  * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new
@@ -20,9 +20,7 @@ type ScrollAdjustments = {
20
20
  const slide = (widget: Gtk.Widget, value: number): Promise<void> =>
21
21
  wrapEvent(widget, () => {
22
22
  if (!(widget instanceof Gtk.Range)) {
23
- throw new TypeError(
24
- `userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`,
25
- );
23
+ throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`);
26
24
  }
27
25
 
28
26
  widget.emit("change-value", Gtk.ScrollType.JUMP, value);
@@ -49,12 +49,7 @@ const getClickPoint = (clicked: Gtk.Widget, carrier: Gtk.Widget): PressPoint =>
49
49
  return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };
50
50
  };
51
51
 
52
- const emitGesture = (
53
- point: PressPoint,
54
- controllers: Gtk.GestureClick[],
55
- nPress: number,
56
- signal: ClickPhase,
57
- ): void => {
52
+ const emitGesture = (point: PressPoint, controllers: Gtk.GestureClick[], nPress: number, signal: ClickPhase): void => {
58
53
  for (const controller of controllers) {
59
54
  controller.emit(signal, nPress, point.x, point.y);
60
55
  }
@@ -235,8 +230,7 @@ const applyContainerClick: NativeClick = (widget, nPress) => {
235
230
  const directClickFor = (widget: Gtk.Widget): DirectClick => {
236
231
  const native = nativeClickFor(widget, true);
237
232
  const container = native === null ? containerFor(widget) : null;
238
- const gestures =
239
- native !== null || container !== null ? getAuthoredClickGestures(widget) : clickGestures(widget);
233
+ const gestures = native !== null || container !== null ? getAuthoredClickGestures(widget) : clickGestures(widget);
240
234
  const target: ClickTarget = { widget, container, gestures, isClaiming: true, native };
241
235
 
242
236
  return { sites: targetSites(widget, target), outcome: native ?? (container === null ? null : applyContainerClick) };
@@ -256,7 +250,6 @@ const deliverClick = (widget: Gtk.Widget, nPress: number): Promise<void> =>
256
250
  applyClickOutcomes(targets, nPress);
257
251
  });
258
252
 
259
- /* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether activation succeeded */
260
253
  const tryActivate = async (widget: Gtk.Widget): Promise<boolean> => {
261
254
  if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {
262
255
  return false;
@@ -26,7 +26,7 @@ const headerIndexFor = (header: Gtk.Widget): number => {
26
26
  const titledColumnFor = (columns: Gtk.ColumnViewColumn[], title: string | null): Gtk.ColumnViewColumn | null => {
27
27
  const matches = columns.filter((column) => column.getTitle() === title);
28
28
 
29
- return matches.length === 1 ? matches[0] ?? null : null;
29
+ return matches.length === 1 ? (matches[0] ?? null) : null;
30
30
  };
31
31
 
32
32
  const columnFor = (header: Gtk.Widget, view: Gtk.ColumnView): Gtk.ColumnViewColumn | null => {