@gtkx/testing 0.1.34 → 0.1.35
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/dist/render.js +7 -18
- package/package.json +4 -4
package/dist/render.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { start, stop } from "@gtkx/ffi";
|
|
2
|
+
import { getCurrentApp, start, stop } from "@gtkx/ffi";
|
|
3
3
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
4
4
|
import { ApplicationWindow, reconciler } from "@gtkx/react";
|
|
5
5
|
import * as queries from "./queries.js";
|
|
6
6
|
import { setScreenRoot } from "./screen.js";
|
|
7
7
|
const APP_ID = "com.gtkx.testing";
|
|
8
|
-
let app = null;
|
|
9
8
|
let container = null;
|
|
10
9
|
const hasGetLabel = (widget) => typeof widget.getLabel === "function";
|
|
11
10
|
const printWidgetTree = (root, indent = 0) => {
|
|
@@ -27,15 +26,7 @@ const update = async (instance, element, fiberRoot) => {
|
|
|
27
26
|
await tick();
|
|
28
27
|
};
|
|
29
28
|
const ensureInitialized = () => {
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
app = reconciler.getApp();
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
app = start(APP_ID);
|
|
36
|
-
reconciler.setApp(app);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
29
|
+
const app = start(APP_ID);
|
|
39
30
|
if (!container) {
|
|
40
31
|
const instance = reconciler.getInstance();
|
|
41
32
|
container = instance.createContainer(app, 0, null, false, null, "", (error) => console.error("Test reconciler error:", error), () => { }, () => { }, () => { }, null);
|
|
@@ -74,7 +65,8 @@ export const render = async (element, options) => {
|
|
|
74
65
|
};
|
|
75
66
|
};
|
|
76
67
|
export const cleanup = async () => {
|
|
77
|
-
if (container
|
|
68
|
+
if (container) {
|
|
69
|
+
const app = getCurrentApp();
|
|
78
70
|
const instance = reconciler.getInstance();
|
|
79
71
|
await update(instance, null, container);
|
|
80
72
|
for (const window of app.getWindows()) {
|
|
@@ -85,10 +77,7 @@ export const cleanup = async () => {
|
|
|
85
77
|
setScreenRoot(null);
|
|
86
78
|
};
|
|
87
79
|
export const teardown = async () => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
app = null;
|
|
92
|
-
container = null;
|
|
93
|
-
}
|
|
80
|
+
await cleanup();
|
|
81
|
+
stop();
|
|
82
|
+
container = null;
|
|
94
83
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/testing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "Testing utilities for GTKX applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gtkx/ffi": "0.1.
|
|
36
|
-
"@gtkx/react": "0.1.
|
|
37
|
-
"@gtkx/native": "0.1.
|
|
35
|
+
"@gtkx/ffi": "0.1.35",
|
|
36
|
+
"@gtkx/react": "0.1.35",
|
|
37
|
+
"@gtkx/native": "0.1.35"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsc -b && cp ../../README.md .",
|