@gtkx/testing 2.0.0-beta.1 → 2.0.0-beta.11
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.
- package/README.md +8 -165
- package/dist/accessible-native.d.ts +1 -1
- package/dist/accessible-native.d.ts.map +1 -1
- package/dist/accessible-native.js +31 -10
- package/dist/accessible-native.js.map +1 -1
- package/dist/build-queries.d.ts +15 -16
- package/dist/build-queries.d.ts.map +1 -1
- package/dist/build-queries.js +25 -23
- package/dist/build-queries.js.map +1 -1
- package/dist/cleanup-registry.d.ts +2 -1
- package/dist/cleanup-registry.d.ts.map +1 -1
- package/dist/cleanup-registry.js +11 -4
- package/dist/cleanup-registry.js.map +1 -1
- package/dist/config.d.ts +3 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/fire-event.d.ts +3 -3
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +14 -4
- package/dist/fire-event.js.map +1 -1
- package/dist/matchers.d.ts +56 -62
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +6 -18
- package/dist/matchers.js.map +1 -1
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +13 -2
- package/dist/pretty-widget.js.map +1 -1
- package/dist/queries.d.ts +7 -7
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +21 -12
- package/dist/queries.js.map +1 -1
- package/dist/query-helpers.d.ts +2 -2
- package/dist/query-helpers.d.ts.map +1 -1
- package/dist/query-helpers.js +10 -3
- package/dist/query-helpers.js.map +1 -1
- package/dist/render-hook.js +3 -3
- package/dist/render-hook.js.map +1 -1
- package/dist/render.d.ts +17 -17
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +66 -62
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts +1 -1
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +2 -1
- package/dist/role-helpers.js.map +1 -1
- package/dist/role-naming.d.ts +2 -1
- package/dist/role-naming.d.ts.map +1 -1
- package/dist/role-naming.js +2 -1
- package/dist/role-naming.js.map +1 -1
- package/dist/screenshot.d.ts +11 -12
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +35 -16
- package/dist/screenshot.js.map +1 -1
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.d.ts.map +1 -1
- package/dist/suggestions.js +5 -3
- package/dist/suggestions.js.map +1 -1
- package/dist/traversal.d.ts +7 -6
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +32 -7
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +13 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/click.d.ts +17 -4
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +28 -9
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/controller.d.ts +5 -5
- package/dist/user-event/controller.d.ts.map +1 -1
- package/dist/user-event/controller.js +7 -4
- package/dist/user-event/controller.js.map +1 -1
- package/dist/user-event/gesture.d.ts +1 -1
- package/dist/user-event/gesture.d.ts.map +1 -1
- package/dist/user-event/gesture.js +103 -29
- package/dist/user-event/gesture.js.map +1 -1
- package/dist/user-event/index.d.ts +22 -22
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +28 -25
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +26 -4
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/list-row-click.d.ts +1 -1
- package/dist/user-event/list-row-click.d.ts.map +1 -1
- package/dist/user-event/list-row-click.js +3 -2
- package/dist/user-event/list-row-click.js.map +1 -1
- package/dist/user-event/pointer.d.ts.map +1 -1
- package/dist/user-event/pointer.js +9 -11
- package/dist/user-event/pointer.js.map +1 -1
- package/dist/user-event/selection.d.ts +2 -2
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +3 -2
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +31 -27
- package/dist/user-event/text.js.map +1 -1
- package/dist/wait-for.d.ts +2 -2
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js +34 -25
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +5 -4
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +85 -41
- package/dist/widget-accessible-properties.js.map +1 -1
- package/dist/widget-getters.d.ts +7 -9
- package/dist/widget-getters.d.ts.map +1 -1
- package/dist/widget-getters.js.map +1 -1
- package/dist/widget-target.d.ts +4 -0
- package/dist/widget-target.d.ts.map +1 -0
- package/dist/widget-target.js +9 -0
- package/dist/widget-target.js.map +1 -0
- package/package.json +14 -11
- package/src/accessible-native.ts +47 -11
- package/src/build-queries.ts +84 -53
- package/src/cleanup-registry.ts +11 -5
- package/src/config.ts +3 -4
- package/src/fire-event.ts +32 -8
- package/src/matchers.ts +69 -93
- package/src/pretty-widget.ts +17 -2
- package/src/queries.ts +68 -31
- package/src/query-helpers.ts +17 -9
- package/src/render-hook.tsx +3 -3
- package/src/render.tsx +71 -79
- package/src/role-helpers.ts +3 -1
- package/src/role-naming.ts +2 -1
- package/src/screenshot.ts +58 -16
- package/src/suggestions.ts +5 -3
- package/src/traversal.ts +47 -13
- package/src/types.ts +17 -15
- package/src/user-event/click.ts +37 -17
- package/src/user-event/controller.ts +10 -7
- package/src/user-event/gesture.ts +142 -33
- package/src/user-event/index.ts +133 -47
- package/src/user-event/keyboard.ts +35 -5
- package/src/user-event/list-row-click.ts +3 -3
- package/src/user-event/pointer.ts +11 -15
- package/src/user-event/selection.ts +5 -4
- package/src/user-event/text.ts +36 -32
- package/src/wait-for.ts +46 -36
- package/src/widget-accessible-properties.ts +112 -52
- package/src/widget-getters.ts +11 -13
- package/src/widget-target.ts +11 -0
package/dist/cleanup-registry.js
CHANGED
|
@@ -2,9 +2,9 @@ const cleanupQueue = new Set();
|
|
|
2
2
|
const addToCleanupQueue = (fn) => {
|
|
3
3
|
cleanupQueue.add(fn);
|
|
4
4
|
};
|
|
5
|
-
const
|
|
5
|
+
const runCleanupCallbacks = async (callbacks) => {
|
|
6
6
|
const failures = [];
|
|
7
|
-
for (const fn of
|
|
7
|
+
for (const fn of callbacks) {
|
|
8
8
|
try {
|
|
9
9
|
await fn();
|
|
10
10
|
}
|
|
@@ -12,10 +12,17 @@ const runCleanup = async () => {
|
|
|
12
12
|
failures.push(error);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
cleanupQueue.clear();
|
|
16
15
|
if (failures.length > 0) {
|
|
17
16
|
throw new AggregateError(failures, "Cleanup failed");
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
|
-
|
|
19
|
+
const runCleanup = async () => {
|
|
20
|
+
try {
|
|
21
|
+
await runCleanupCallbacks(cleanupQueue);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
cleanupQueue.clear();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export { addToCleanupQueue, runCleanup, runCleanupCallbacks };
|
|
21
28
|
//# sourceMappingURL=cleanup-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup-registry.js","sourceRoot":"","sources":["../src/cleanup-registry.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAyB,IAAI,GAAG,EAAE,CAAC;AAErD,MAAM,iBAAiB,GAAG,CAAC,EAAmB,EAAQ,EAAE;IACpD,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,
|
|
1
|
+
{"version":3,"file":"cleanup-registry.js","sourceRoot":"","sources":["../src/cleanup-registry.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAyB,IAAI,GAAG,EAAE,CAAC;AAErD,MAAM,iBAAiB,GAAG,CAAC,EAAmB,EAAQ,EAAE;IACpD,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,KAAK,EAAE,SAAoC,EAAiB,EAAE;IACtF,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QACzB,IAAI,CAAC;YACD,MAAM,EAAE,EAAE,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACzD,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,IAAmB,EAAE;IACzC,IAAI,CAAC;QACD,MAAM,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;YAAS,CAAC;QACP,YAAY,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["type CleanupFunction = () => void | Promise<void>;\n\nconst cleanupQueue: Set<CleanupFunction> = new Set();\n\nconst addToCleanupQueue = (fn: CleanupFunction): void => {\n cleanupQueue.add(fn);\n};\n\nconst runCleanupCallbacks = async (callbacks: Iterable<CleanupFunction>): Promise<void> => {\n const failures: unknown[] = [];\n\n for (const fn of callbacks) {\n try {\n await fn();\n } catch (error) {\n failures.push(error);\n }\n }\n\n if (failures.length > 0) {\n throw new AggregateError(failures, \"Cleanup failed\");\n }\n};\n\nconst runCleanup = async (): Promise<void> => {\n try {\n await runCleanupCallbacks(cleanupQueue);\n } finally {\n cleanupQueue.clear();\n }\n};\n\nexport { addToCleanupQueue, runCleanup, runCleanupCallbacks };\n"]}
|
package/dist/config.d.ts
CHANGED
|
@@ -14,10 +14,9 @@ type Config = {
|
|
|
14
14
|
/** Timeout in milliseconds a user event waits for its widget to become actionable. */
|
|
15
15
|
actionabilityTimeout: number;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* how long a window that never activates takes to report, and costs nothing when one does.
|
|
17
|
+
* Maximum milliseconds `render` waits for window layout and activation. Activation needs a
|
|
18
|
+
* compositor round trip, so this is longer than {@link Config.actionabilityTimeout}. Rendering
|
|
19
|
+
* resolves as soon as activation succeeds, without waiting out the timeout.
|
|
21
20
|
*/
|
|
22
21
|
windowActivationTimeout: number;
|
|
23
22
|
};
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,KAAK,MAAM,GAAG;IACV,+FAA+F;IAC/F,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0FAA0F;IAC1F,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC;IAEnE,2EAA2E;IAC3E,gBAAgB,EAAE,MAAM,CAAC;IAEzB,sFAAsF;IACtF,oBAAoB,EAAE,MAAM,CAAC;IAE7B
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,KAAK,MAAM,GAAG;IACV,+FAA+F;IAC/F,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0FAA0F;IAC1F,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC;IAEnE,2EAA2E;IAC3E,gBAAgB,EAAE,MAAM,CAAC;IAEzB,sFAAsF;IACtF,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,uBAAuB,EAAE,MAAM,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,KAAK,QAAQ,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAgB5D;;GAEG;AACH,QAAA,MAAM,SAAS,QAAO,MAAuB,CAAC;AAE9C;;;;;GAKG;AACH,QAAA,MAAM,SAAS,GAAI,WAAW,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,KAAG,IAG1D,CAAC;AAMF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,CAAC"}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAkCA,MAAM,aAAa,GAAW;IAC1B,gBAAgB,EAAE,KAAK;IACvB,eAAe,EAAE,sBAAsB;IACvC,gBAAgB,EAAE,IAAI;IACtB,oBAAoB,EAAE,GAAG;IACzB,uBAAuB,EAAE,IAAI;CAChC,CAAC;AAEF,MAAM,aAAa,GAAW,EAAE,GAAG,aAAa,EAAE,CAAC;AAEnD,SAAS,sBAAsB,CAAC,OAAe;IAC3C,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,SAAS,GAAG,GAAW,EAAE,CAAC,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,SAAqC,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvF,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,YAAa,SAAQ,KAAK;IACnB,IAAI,GAAG,cAAc,CAAC;CAClC;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAA8B,CAAC","sourcesContent":["import type { Container } from \"./traversal.js\";\n\n/**\n * Global configuration for the testing harness, controlling query behavior,\n * error formatting, and the timeouts used by async utilities and actionability\n * checks.\n */\ntype Config = {\n /** Whether a successful query throws instead, naming a better query, when one is available. */\n throwSuggestions: boolean;\n\n /** Builds the error thrown when a query fails, given a message and optional container. */\n getElementError: (message: string, container?: Container) => Error;\n\n /** Default timeout in milliseconds for async utilities such as waitFor. */\n asyncUtilTimeout: number;\n\n /** Timeout in milliseconds a user event waits for its widget to become actionable. */\n actionabilityTimeout: number;\n\n /**\n * Maximum milliseconds `render` waits for window layout and activation. Activation needs a\n * compositor round trip, so this is longer than {@link Config.actionabilityTimeout}. Rendering\n * resolves as soon as activation succeeds, without waiting out the timeout.\n */\n windowActivationTimeout: number;\n};\n\n/**\n * Function form of a configuration update: receives the current config and\n * returns the fields to override.\n */\ntype ConfigFn = (existingConfig: Config) => Partial<Config>;\n\nconst defaultConfig: Config = {\n throwSuggestions: false,\n getElementError: defaultGetElementError,\n asyncUtilTimeout: 1000,\n actionabilityTimeout: 500,\n windowActivationTimeout: 5000,\n};\n\nconst currentConfig: Config = { ...defaultConfig };\n\nfunction defaultGetElementError(message: string): Error {\n return new ElementError(message);\n}\n\n/**\n * Returns the current global testing configuration.\n */\nconst getConfig = (): Config => currentConfig;\n\n/**\n * Merges the given overrides into the global testing configuration.\n *\n * @param newConfig Either a partial config object or a function that receives\n * the current config and returns the fields to override.\n */\nconst configure = (newConfig: Partial<Config> | ConfigFn): void => {\n const updates = typeof newConfig === \"function\" ? newConfig(currentConfig) : newConfig;\n Object.assign(currentConfig, updates);\n};\n\nclass ElementError extends Error {\n override name = \"ElementError\";\n}\n\nexport { getConfig, configure, type Config, type ConfigFn };\n"]}
|
package/dist/fire-event.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as GObject from "@gtkx/gi/gobject";
|
|
|
5
5
|
*/
|
|
6
6
|
type WidgetEvent = {
|
|
7
7
|
/** The GObject instance the signal is emitted on. */
|
|
8
|
-
target: GObject.Object
|
|
8
|
+
target: Pick<GObject.Object, "__type__">;
|
|
9
9
|
/** Name of the signal to emit. */
|
|
10
10
|
signalName: string;
|
|
11
11
|
/** Arguments passed to the signal handlers. */
|
|
@@ -20,7 +20,7 @@ type WidgetEvent = {
|
|
|
20
20
|
* @param args Arguments to pass to the signal handlers.
|
|
21
21
|
* @returns The recorded emission.
|
|
22
22
|
*/
|
|
23
|
-
declare const createEvent: (target: GObject.Object, signalName: string, ...args: unknown[]) => WidgetEvent;
|
|
23
|
+
declare const createEvent: (target: Pick<GObject.Object, "__type__">, signalName: string, ...args: unknown[]) => WidgetEvent;
|
|
24
24
|
/**
|
|
25
25
|
* Emits a recorded signal emission inside React's act environment, so any resulting state updates are
|
|
26
26
|
* flushed before the promise resolves.
|
|
@@ -36,6 +36,6 @@ declare function fireEvent(event: WidgetEvent): Promise<void>;
|
|
|
36
36
|
* @param signalName Name of the signal to emit.
|
|
37
37
|
* @param args Arguments passed to the signal handlers.
|
|
38
38
|
*/
|
|
39
|
-
declare function fireEvent(target: GObject.Object, signalName: string, ...args: unknown[]): Promise<void>;
|
|
39
|
+
declare function fireEvent(target: Pick<GObject.Object, "__type__">, signalName: string, ...args: unknown[]): Promise<void>;
|
|
40
40
|
export { createEvent, fireEvent, type WidgetEvent };
|
|
41
41
|
//# sourceMappingURL=fire-event.d.ts.map
|
package/dist/fire-event.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fire-event.d.ts","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C;;;GAGG;AACH,KAAK,WAAW,GAAG;IACf,qDAAqD;IACrD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"fire-event.d.ts","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C;;;GAGG;AACH,KAAK,WAAW,GAAG;IACf,qDAAqD;IACrD,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACzC,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,IAAI,EAAE,OAAO,EAAE,CAAC;CACnB,CAAC;AAUF;;;;;;;;GAQG;AACH,QAAA,MAAM,WAAW,GACb,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EACxC,YAAY,MAAM,EAClB,GAAG,MAAM,OAAO,EAAE,KACnB,WAID,CAAC;AAcH;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACtD;;;;;;;GAOG;AACH,iBAAS,SAAS,CACd,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EACxC,UAAU,EAAE,MAAM,EAClB,GAAG,IAAI,EAAE,OAAO,EAAE,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;AAoBjB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
package/dist/fire-event.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as GObject from "@gtkx/gi/gobject";
|
|
2
2
|
import { runInAct } from "./act.js";
|
|
3
|
+
const requireObject = (target) => {
|
|
4
|
+
if (!(target instanceof GObject.Object)) {
|
|
5
|
+
throw new TypeError("Expected a GObject instance");
|
|
6
|
+
}
|
|
7
|
+
return target;
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
10
|
* Records a signal emission without delivering it, so it can be inspected or held and passed to
|
|
5
11
|
* {@link fireEvent} later.
|
|
@@ -10,23 +16,27 @@ import { runInAct } from "./act.js";
|
|
|
10
16
|
* @returns The recorded emission.
|
|
11
17
|
*/
|
|
12
18
|
const createEvent = (target, signalName, ...args) => ({
|
|
13
|
-
target,
|
|
19
|
+
target: requireObject(target),
|
|
14
20
|
signalName,
|
|
15
21
|
args,
|
|
16
22
|
});
|
|
17
23
|
const dispatchEvent = async (event) => {
|
|
24
|
+
const target = requireObject(event.target);
|
|
18
25
|
await runInAct(() => {
|
|
19
|
-
|
|
26
|
+
Reflect.apply(GObject.signalEmit, undefined, [target, event.signalName, ...event.args]);
|
|
20
27
|
});
|
|
21
28
|
};
|
|
29
|
+
const isWidgetEvent = (value) => "target" in value && "signalName" in value && "args" in value &&
|
|
30
|
+
typeof value.signalName === "string" && Array.isArray(value.args);
|
|
22
31
|
function fireEvent(eventOrTarget, signalName, ...args) {
|
|
23
|
-
if (
|
|
32
|
+
if (signalName === undefined && isWidgetEvent(eventOrTarget)) {
|
|
24
33
|
return dispatchEvent(eventOrTarget);
|
|
25
34
|
}
|
|
26
35
|
if (signalName === undefined) {
|
|
27
36
|
throw new Error("Unable to fire an event: pass a signal name, or an event built by createEvent.");
|
|
28
37
|
}
|
|
29
|
-
|
|
38
|
+
const target = requireObject(eventOrTarget);
|
|
39
|
+
return dispatchEvent({ target, signalName, args });
|
|
30
40
|
}
|
|
31
41
|
export { createEvent, fireEvent };
|
|
32
42
|
//# sourceMappingURL=fire-event.js.map
|
package/dist/fire-event.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fire-event.js","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAA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,SAAS,SAAS,CACd,aAA6D,EAC7D,UAAmB,EACnB,GAAG,IAAe;IAElB,IAAI,UAAU,KAAK,SAAS,IAAI,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC;QAC3D,OAAO,aAAa,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACtG,CAAC;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAE5C,OAAO,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,SAAS,EAAoB,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport { runInAct } from \"./act.js\";\n\n/**\n * A signal emission built but not yet delivered. GObject has no event object to construct, so this\n * records the target, signal, and arguments {@link fireEvent} will emit.\n */\ntype WidgetEvent = {\n /** The GObject instance the signal is emitted on. */\n target: Pick<GObject.Object, \"__type__\">;\n /** Name of the signal to emit. */\n signalName: string;\n /** Arguments passed to the signal handlers. */\n args: unknown[];\n};\n\nconst requireObject = (target: object): GObject.Object => {\n if (!(target instanceof GObject.Object)) {\n throw new TypeError(\"Expected a GObject instance\");\n }\n\n return target;\n};\n\n/**\n * Records a signal emission without delivering it, so it can be inspected or held and passed to\n * {@link fireEvent} later.\n *\n * @param target The GObject instance the signal would be emitted on.\n * @param signalName Name of the signal to emit.\n * @param args Arguments to pass to the signal handlers.\n * @returns The recorded emission.\n */\nconst createEvent = (\n target: Pick<GObject.Object, \"__type__\">,\n signalName: string,\n ...args: unknown[]\n): WidgetEvent => ({\n target: requireObject(target),\n signalName,\n args,\n});\n\nconst dispatchEvent = async (event: WidgetEvent): Promise<void> => {\n const target = requireObject(event.target);\n\n await runInAct(() => {\n Reflect.apply(GObject.signalEmit, undefined, [target, event.signalName, ...event.args]);\n });\n};\n\nconst isWidgetEvent = (value: object): value is WidgetEvent =>\n \"target\" in value && \"signalName\" in value && \"args\" in value &&\n typeof value.signalName === \"string\" && Array.isArray(value.args);\n\n/**\n * Emits a recorded signal emission inside React's act environment, so any resulting state updates are\n * flushed before the promise resolves.\n *\n * @param event An emission built by {@link createEvent}.\n */\nfunction fireEvent(event: WidgetEvent): Promise<void>;\n/**\n * Emits a GObject signal on a widget or object inside React's act environment, so any resulting state\n * updates are flushed before the promise resolves.\n *\n * @param target The GObject instance to emit the signal on.\n * @param signalName Name of the signal to emit.\n * @param args Arguments passed to the signal handlers.\n */\nfunction fireEvent(\n target: Pick<GObject.Object, \"__type__\">,\n signalName: string,\n ...args: unknown[]\n): Promise<void>;\n\nfunction fireEvent(\n eventOrTarget: WidgetEvent | Pick<GObject.Object, \"__type__\">,\n signalName?: string,\n ...args: unknown[]\n): Promise<void> {\n if (signalName === undefined && isWidgetEvent(eventOrTarget)) {\n return dispatchEvent(eventOrTarget);\n }\n\n if (signalName === undefined) {\n throw new Error(\"Unable to fire an event: pass a signal name, or an event built by createEvent.\");\n }\n\n const target = requireObject(eventOrTarget);\n\n return dispatchEvent({ target, signalName, args });\n}\n\nexport { createEvent, fireEvent, type WidgetEvent };\n"]}
|
package/dist/matchers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SyncMatcherResult } from "vitest";
|
|
2
2
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
3
|
import type { ByRoleOptions, Matcher, MatcherOptions } from "./types.js";
|
|
4
4
|
import { type AccessibleAttributeValue } from "./accessible-native.js";
|
|
@@ -15,7 +15,7 @@ type TextContentOptions = {
|
|
|
15
15
|
/** The expected value for a style class: an exact class name or a regular expression. */
|
|
16
16
|
type ClassExpectation = string | RegExp;
|
|
17
17
|
/** The outcome of a matcher: whether it passed, and the failure text built on demand. */
|
|
18
|
-
type MatcherResult = Pick<
|
|
18
|
+
type MatcherResult = Pick<SyncMatcherResult, "message" | "pass">;
|
|
19
19
|
/** The matcher state bound as `this`, supplying the test runner's deep equality check. */
|
|
20
20
|
type MatcherContext = {
|
|
21
21
|
/** Compares a received value against an expected one, resolving asymmetric matchers. */
|
|
@@ -95,22 +95,20 @@ type MatcherImplementations = {
|
|
|
95
95
|
/**
|
|
96
96
|
* Asserts a widget's numeric value, or its display value when a string is given.
|
|
97
97
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* the same tree, where the maximum of a paged widget such as a scrollbar is the last value it can
|
|
103
|
-
* reach, its adjustment's upper bound less one page.
|
|
98
|
+
* Numeric values come from GTK's accessibility tree, which ignores updates smaller than 0.001.
|
|
99
|
+
* Comparisons use that tolerance, matching `ByRole`'s `value` option and
|
|
100
|
+
* `toHaveAccessibleProperty`. For paged widgets such as scrollbars, the accessible maximum is
|
|
101
|
+
* the adjustment's upper bound minus its page size.
|
|
104
102
|
*/
|
|
105
103
|
toHaveValue: (received: unknown, expected?: number | string) => MatcherResult;
|
|
106
104
|
/** Asserts the widget's accessible role. */
|
|
107
105
|
toHaveRole: (received: unknown, expected: Gtk.AccessibleRole) => MatcherResult;
|
|
108
106
|
/** Asserts the widget is, or is an ancestor of, the given widget. */
|
|
109
|
-
toContainElement: (received: unknown, descendant: Gtk.
|
|
107
|
+
toContainElement: (received: unknown, descendant: Gtk.Accessible | null) => MatcherResult;
|
|
110
108
|
/** Asserts the widget comes before the given widget in the widget tree, neither containing the other. */
|
|
111
|
-
toAppearBefore: (received: unknown, other: Gtk.
|
|
109
|
+
toAppearBefore: (received: unknown, other: Gtk.Accessible) => MatcherResult;
|
|
112
110
|
/** Asserts the widget comes after the given widget in the widget tree, neither containing the other. */
|
|
113
|
-
toAppearAfter: (received: unknown, other: Gtk.
|
|
111
|
+
toAppearAfter: (received: unknown, other: Gtk.Accessible) => MatcherResult;
|
|
114
112
|
/** Asserts at least one widget under the received one matches the `ByRole` query. */
|
|
115
113
|
toContainAnyByRole: ContainmentMatcher<RoleQueryArgs>;
|
|
116
114
|
/** Asserts exactly one widget under the received one matches the `ByRole` query. */
|
|
@@ -146,59 +144,55 @@ type MatcherImplementations = {
|
|
|
146
144
|
declare const matchers: MatcherImplementations;
|
|
147
145
|
/** Registers the widget matchers on the global `expect`, when one is available. Safe to call more than once. */
|
|
148
146
|
declare const registerMatchers: () => void;
|
|
149
|
-
declare module "
|
|
150
|
-
interface
|
|
151
|
-
toHaveDisplayValue(expected?: TextExpectation):
|
|
152
|
-
toHaveTextContent(expected?: TextExpectation, options?: TextContentOptions):
|
|
153
|
-
toHaveAccessibleName(expected?: TextExpectation):
|
|
154
|
-
toHaveAccessibleDescription(expected?: TextExpectation):
|
|
155
|
-
toHaveAccessibleErrorMessage(expected?: TextExpectation):
|
|
156
|
-
toHaveSelection(expected?: TextExpectation):
|
|
157
|
-
toHaveAccessibleState(state: BooleanAccessibleState, expected?: boolean):
|
|
158
|
-
toHaveAccessibleState(state: TristateAccessibleState, expected?: Gtk.AccessibleTristate):
|
|
159
|
-
toHaveAccessibleState(state: Gtk.AccessibleState.INVALID, expected?: Gtk.AccessibleInvalidState):
|
|
160
|
-
toHaveAccessibleProperty(property: StringAccessibleProperty, expected?: string):
|
|
161
|
-
toHaveAccessibleProperty(property: BooleanAccessibleProperty, expected?: boolean):
|
|
162
|
-
toHaveAccessibleProperty(property: NumberAccessibleProperty, expected?: number):
|
|
163
|
-
toHaveAccessibleProperty(property: Gtk.AccessibleProperty.AUTOCOMPLETE, expected?: Gtk.AccessibleAutocomplete):
|
|
164
|
-
toHaveAccessibleProperty(property: Gtk.AccessibleProperty.ORIENTATION, expected?: Gtk.Orientation):
|
|
165
|
-
toHaveAccessibleProperty(property: Gtk.AccessibleProperty.SORT, expected?: Gtk.AccessibleSort):
|
|
166
|
-
toBeChecked():
|
|
167
|
-
toBePartiallyChecked():
|
|
168
|
-
toBePressed():
|
|
169
|
-
toBePartiallyPressed():
|
|
170
|
-
toBeDisabled():
|
|
171
|
-
toBeEnabled():
|
|
172
|
-
toBeVisible():
|
|
173
|
-
toBeRooted():
|
|
174
|
-
toBeEmptyWidget():
|
|
175
|
-
toBeInvalid():
|
|
176
|
-
toBeValid():
|
|
177
|
-
toBeRequired():
|
|
178
|
-
toHaveFocus():
|
|
179
|
-
toHaveValue(expected?: number | string):
|
|
180
|
-
toHaveRole(expected: Gtk.AccessibleRole):
|
|
181
|
-
toContainElement(descendant: Gtk.
|
|
182
|
-
toAppearBefore(other: Gtk.
|
|
183
|
-
toAppearAfter(other: Gtk.
|
|
184
|
-
toContainAnyByRole(...args: RoleQueryArgs):
|
|
185
|
-
toContainOneByRole(...args: RoleQueryArgs):
|
|
186
|
-
toContainAnyByText(...args: TextQueryArgs):
|
|
187
|
-
toContainOneByText(...args: TextQueryArgs):
|
|
188
|
-
toContainAnyByLabelText(...args: TextQueryArgs):
|
|
189
|
-
toContainOneByLabelText(...args: TextQueryArgs):
|
|
190
|
-
toContainAnyByPlaceholderText(...args: TextQueryArgs):
|
|
191
|
-
toContainOneByPlaceholderText(...args: TextQueryArgs):
|
|
192
|
-
toContainAnyByDisplayValue(...args: TextQueryArgs):
|
|
193
|
-
toContainOneByDisplayValue(...args: TextQueryArgs):
|
|
147
|
+
declare module "vitest" {
|
|
148
|
+
interface Matchers<R extends void | Promise<void> = void | Promise<void>, T = unknown> {
|
|
149
|
+
toHaveDisplayValue(expected?: TextExpectation): R;
|
|
150
|
+
toHaveTextContent(expected?: TextExpectation, options?: TextContentOptions): R;
|
|
151
|
+
toHaveAccessibleName(expected?: TextExpectation): R;
|
|
152
|
+
toHaveAccessibleDescription(expected?: TextExpectation): R;
|
|
153
|
+
toHaveAccessibleErrorMessage(expected?: TextExpectation): R;
|
|
154
|
+
toHaveSelection(expected?: TextExpectation): R;
|
|
155
|
+
toHaveAccessibleState(state: BooleanAccessibleState, expected?: boolean): R;
|
|
156
|
+
toHaveAccessibleState(state: TristateAccessibleState, expected?: Gtk.AccessibleTristate): R;
|
|
157
|
+
toHaveAccessibleState(state: Gtk.AccessibleState.INVALID, expected?: Gtk.AccessibleInvalidState): R;
|
|
158
|
+
toHaveAccessibleProperty(property: StringAccessibleProperty, expected?: string): R;
|
|
159
|
+
toHaveAccessibleProperty(property: BooleanAccessibleProperty, expected?: boolean): R;
|
|
160
|
+
toHaveAccessibleProperty(property: NumberAccessibleProperty, expected?: number): R;
|
|
161
|
+
toHaveAccessibleProperty(property: Gtk.AccessibleProperty.AUTOCOMPLETE, expected?: Gtk.AccessibleAutocomplete): R;
|
|
162
|
+
toHaveAccessibleProperty(property: Gtk.AccessibleProperty.ORIENTATION, expected?: Gtk.Orientation): R;
|
|
163
|
+
toHaveAccessibleProperty(property: Gtk.AccessibleProperty.SORT, expected?: Gtk.AccessibleSort): R;
|
|
164
|
+
toBeChecked(): R;
|
|
165
|
+
toBePartiallyChecked(): R;
|
|
166
|
+
toBePressed(): R;
|
|
167
|
+
toBePartiallyPressed(): R;
|
|
168
|
+
toBeDisabled(): R;
|
|
169
|
+
toBeEnabled(): R;
|
|
170
|
+
toBeVisible(): R;
|
|
171
|
+
toBeRooted(): R;
|
|
172
|
+
toBeEmptyWidget(): R;
|
|
173
|
+
toBeInvalid(): R;
|
|
174
|
+
toBeValid(): R;
|
|
175
|
+
toBeRequired(): R;
|
|
176
|
+
toHaveFocus(): R;
|
|
177
|
+
toHaveValue(expected?: number | string): R;
|
|
178
|
+
toHaveRole(expected: Gtk.AccessibleRole): R;
|
|
179
|
+
toContainElement(descendant: Gtk.Accessible | null): R;
|
|
180
|
+
toAppearBefore(other: Gtk.Accessible): R;
|
|
181
|
+
toAppearAfter(other: Gtk.Accessible): R;
|
|
182
|
+
toContainAnyByRole(...args: RoleQueryArgs): R;
|
|
183
|
+
toContainOneByRole(...args: RoleQueryArgs): R;
|
|
184
|
+
toContainAnyByText(...args: TextQueryArgs): R;
|
|
185
|
+
toContainOneByText(...args: TextQueryArgs): R;
|
|
186
|
+
toContainAnyByLabelText(...args: TextQueryArgs): R;
|
|
187
|
+
toContainOneByLabelText(...args: TextQueryArgs): R;
|
|
188
|
+
toContainAnyByPlaceholderText(...args: TextQueryArgs): R;
|
|
189
|
+
toContainOneByPlaceholderText(...args: TextQueryArgs): R;
|
|
190
|
+
toContainAnyByDisplayValue(...args: TextQueryArgs): R;
|
|
191
|
+
toContainOneByDisplayValue(...args: TextQueryArgs): R;
|
|
194
192
|
toHaveClass(...args: (ClassExpectation | {
|
|
195
193
|
exact: boolean;
|
|
196
|
-
})[]):
|
|
197
|
-
toHaveObjectProperty(name: string, expected?: unknown):
|
|
198
|
-
}
|
|
199
|
-
interface Assertion extends WidgetMatchers {
|
|
200
|
-
}
|
|
201
|
-
interface AsymmetricMatchersContaining extends WidgetMatchers {
|
|
194
|
+
})[]): R;
|
|
195
|
+
toHaveObjectProperty(name: string, expected?: unknown): R;
|
|
202
196
|
}
|
|
203
197
|
}
|
|
204
198
|
export { matchers, registerMatchers, type ClassExpectation, type TextContentOptions, type TextExpectation };
|
package/dist/matchers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAEH,KAAK,wBAAwB,EAKhC,MAAM,wBAAwB,CAAC;AAiChC,sFAAsF;AACtF,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC,gFAAgF;AAChF,KAAK,kBAAkB,GAAG;IACtB;;;OAGG;IACH,mBAAmB,CA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,CAAC,CAAC;QACxC,kBAAkB,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QAC9C,kBAAkB,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QAC9C,kBAAkB,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QAC9C,kBAAkB,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QAC9C,uBAAuB,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QACnD,uBAAuB,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QACnD,6BAA6B,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QACzD,6BAA6B,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QACzD,0BAA0B,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QACtD,0BAA0B,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,CAAC,CAAC;QACtD,WAAW,CAAC,GAAG,IAAI,EAAE,CAAC,gBAAgB,GAAG;YAAE,KAAK,EAAE,OAAO,CAAA;SAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QACnE,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC;KAC7D;CAEJ;AAED,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
package/dist/matchers.js
CHANGED
|
@@ -176,7 +176,6 @@ const isAppearingBefore = (first, second) => {
|
|
|
176
176
|
const root = getTreeRoot(first);
|
|
177
177
|
return isSeparateWidget(first, second) && root === getTreeRoot(second) && isPrecedingWidget(root, first, second);
|
|
178
178
|
};
|
|
179
|
-
const camelCase = (name) => name.replaceAll(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
180
179
|
const isAsymmetricMatcher = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "asymmetricMatch") === "function";
|
|
181
180
|
const isEqualValue = (context, actual, expected) => {
|
|
182
181
|
if (isAsymmetricMatcher(expected)) {
|
|
@@ -187,7 +186,7 @@ const isEqualValue = (context, actual, expected) => {
|
|
|
187
186
|
}
|
|
188
187
|
return context.equals(actual, expected);
|
|
189
188
|
};
|
|
190
|
-
const isClassMatch = (actual, expected) =>
|
|
189
|
+
const isClassMatch = (actual, expected) => actual.some((name) => isTextMatch(name, expected, "exact"));
|
|
191
190
|
const isWidgetRooted = (widget) => {
|
|
192
191
|
const root = widget.getRoot();
|
|
193
192
|
if (root === null) {
|
|
@@ -217,20 +216,8 @@ function readErrorMessageText(widget) {
|
|
|
217
216
|
const texts = targets.map((target) => getWidgetAccessibleName(target)).filter((text) => text !== null);
|
|
218
217
|
return texts.length > 0 ? texts.join(" ") : null;
|
|
219
218
|
}
|
|
220
|
-
function assertReadableProperty(object, name, property, value) {
|
|
221
|
-
if (typeof value === "function") {
|
|
222
|
-
throw new TypeError(`toHaveObjectProperty: "${name}" is shadowed by a method of the same name; ` +
|
|
223
|
-
`call ${property}() and assert on its result instead`);
|
|
224
|
-
}
|
|
225
|
-
if (value === undefined && !Reflect.has(object, property)) {
|
|
226
|
-
throw new TypeError(`toHaveObjectProperty: no readable property "${name}" on ${describeObject(object)}; ` +
|
|
227
|
-
"construct-only and write-only properties cannot be read back");
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
219
|
function readObjectProperty(object, name) {
|
|
231
|
-
const
|
|
232
|
-
const value = Reflect.get(object, property);
|
|
233
|
-
assertReadableProperty(object, name, property, value);
|
|
220
|
+
const value = Reflect.apply(GObject.getProperty, undefined, [object, name]);
|
|
234
221
|
return value;
|
|
235
222
|
}
|
|
236
223
|
function classEntries(entry) {
|
|
@@ -425,7 +412,7 @@ function toBeRooted(received) {
|
|
|
425
412
|
}
|
|
426
413
|
function toBeEmptyWidget(received) {
|
|
427
414
|
const widget = asWidget(received, "toBeEmptyWidget");
|
|
428
|
-
return stateResult(widget, "empty", widget.getFirstChild() === null && getWidgetLabelText(widget)
|
|
415
|
+
return stateResult(widget, "empty", widget.getFirstChild() === null && !getWidgetLabelText(widget));
|
|
429
416
|
}
|
|
430
417
|
function toBeInvalid(received) {
|
|
431
418
|
const widget = asWidget(received, "toBeInvalid");
|
|
@@ -453,11 +440,12 @@ function toHaveRole(received, expected) {
|
|
|
453
440
|
}
|
|
454
441
|
function toContainElement(received, descendant) {
|
|
455
442
|
const widget = asWidget(received, "toContainElement");
|
|
456
|
-
const
|
|
443
|
+
const target = descendant === null ? null : asWidget(descendant, "toContainElement");
|
|
444
|
+
const isPass = target !== null && (target === widget || target.isAncestor(widget));
|
|
457
445
|
return {
|
|
458
446
|
pass: isPass,
|
|
459
447
|
message: () => `expected widget ${negationPrefix(isPass)}to contain ` +
|
|
460
|
-
`${
|
|
448
|
+
`${target === null ? "null" : describeWidget(target)}\n${describeWidget(widget)}`,
|
|
461
449
|
};
|
|
462
450
|
}
|
|
463
451
|
function toHaveClass(received, ...args) {
|