Skip to content

Commit 2a6360d

Browse files
committed
Adjust tests
1 parent ba6c26e commit 2a6360d

File tree

5 files changed

+44
-16
lines changed

5 files changed

+44
-16
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ jobs:
4242
- name: Run Unit Tests - Linux
4343
if: matrix.os == 'ubuntu-22.04'
4444
run: |
45-
patchelf --force-rpath --set-rpath '$ORIGIN:$ORIGIN/../node_modules/deps-qt-core-raub/bin-linux:$ORIGIN/../node_modules/deps-qt-gui-raub/bin-linux:$ORIGIN/../node_modules/deps-qt-qml-raub/bin-linux:$ORIGIN/../../deps-qt-core-raub/bin-linux:$ORIGIN/../../deps-qt-gui-raub/bin-linux:$ORIGIN/../../deps-qt-qml-raub/bin-linux' $GITHUB_WORKSPACE/node_modules/deps-qmlui-raub/bin-linux/libqmlui.so
46-
sudo apt-get update
45+
# patchelf --force-rpath --set-rpath '$ORIGIN:$ORIGIN/../node_modules/deps-qt-core-raub/bin-linux:$ORIGIN/../node_modules/deps-qt-gui-raub/bin-linux:$ORIGIN/../node_modules/deps-qt-qml-raub/bin-linux:$ORIGIN/../../deps-qt-core-raub/bin-linux:$ORIGIN/../../deps-qt-gui-raub/bin-linux:$ORIGIN/../../deps-qt-qml-raub/bin-linux' $GITHUB_WORKSPACE/node_modules/deps-qmlui-raub/bin-linux/libqmlui.so
46+
sudo apt-get update -qq
4747
sudo apt-get install -qq libgles2-mesa-dev libxcb-cursor0 libxcb-icccm4 libxcb-keysyms1 libxcb-shape0 libxcb-xkb1 libxkbcommon-x11-0
48-
# LD_DEBUG=libs node .
49-
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/ci
50-
LD_DEBUG=libs xvfb-run --auto-servernum npm run test-ci
51-
# cd test && LD_DEBUG=libs xvfb-run --auto-servernum node debug.js
52-
# xvfb-run --auto-servernum npm run test-ci
48+
# LD_DEBUG=libs xvfb-run --auto-servernum npm run test-ci
49+
xvfb-run --auto-servernum npm run test-ci
5350
5451
# - name: Run Unit Tests - MacOS
5552
# if: matrix.os == 'macos-14'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "QML interoperation for Node.js",
66
"license": "MIT",
77
"main": "index.js",
8+
"type": "commonjs",
89
"keywords": [
910
"addon",
1011
"qml",

test/method.test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const { View, Method } = require('./init');
88

99

1010
const view = new View({ file: 'test.qml', silent: true });
11+
const loadPromise = Promise.race([
12+
new Promise((res) => { setTimeout(() => res(false), 5000); }),
13+
new Promise((res) => view.on('load', () => res(true))),
14+
]);
1115
view.on('error', () => {});
1216

1317
const opts = { view, name: 'obj1', key: 'method1' };
@@ -26,6 +30,9 @@ const tested = describe('Method', () => {
2630
});
2731

2832
it('calls QML method1', async () => {
33+
const loaded = await loadPromise;
34+
assert.strictEqual(loaded, true);
35+
2936
const method1 = new Method(opts);
3037
const called = await new Promise((res) => {
3138
view.on('m1c', () => res(true));
@@ -35,6 +42,9 @@ const tested = describe('Method', () => {
3542
});
3643

3744
it('calls QML method2', async () => {
45+
const loaded = await loadPromise;
46+
assert.strictEqual(loaded, true);
47+
3848
const method2 = new Method({ ...opts, key: 'method2' });
3949
const called = await new Promise((res) => {
4050
view.on('m2c', () => res(true));
@@ -43,12 +53,18 @@ const tested = describe('Method', () => {
4353
assert.strictEqual(called, true);
4454
});
4555

46-
it('calls non-existent object\'s method, and gets null', () => {
56+
it('calls non-existent object\'s method, and gets null', async () => {
57+
const loaded = await loadPromise;
58+
assert.strictEqual(loaded, true);
59+
4760
const method = new Method({ ...opts, name: 'awdaldaklwd23' });
4861
assert.strictEqual(method(), null);
4962
});
5063

51-
it('calls non-existent method, and gets null', () => {
64+
it('calls non-existent method, and gets null', async () => {
65+
const loaded = await loadPromise;
66+
assert.strictEqual(loaded, true);
67+
5268
const method = new Method({ ...opts, key: 'awdaldaklwd23' });
5369
assert.strictEqual(method(), null);
5470
});

test/property.test.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const { View, Property } = require('./init');
88

99

1010
const view = new View({ file: 'test.qml', silent: true });
11-
const loadPromise = new Promise((res) => view.on('load', () => res(true)));
11+
const loadPromise = Promise.race([
12+
new Promise((res) => { setTimeout(() => res(false), 5000); }),
13+
new Promise((res) => view.on('load', () => res(true))),
14+
]);
1215
view.on('error', () => {});
1316

1417
const opts = { view, name: 'obj1', key: 'prop1' };
@@ -27,13 +30,15 @@ const tested = describe('Property', () => {
2730
});
2831

2932
it('reads a value from QML', async () => {
30-
await loadPromise;
33+
const loaded = await loadPromise;
34+
assert.strictEqual(loaded, true);
3135
const prop = new Property(opts);
3236
assert.strictEqual(prop.value, 'value1');
3337
});
3438

3539
it('changes a QML value', async () => {
36-
await loadPromise;
40+
const loaded = await loadPromise;
41+
assert.strictEqual(loaded, true);
3742
const prop = new Property(opts);
3843
const changed = await new Promise((res) => {
3944
view.on('p1c', () => res(true));
@@ -43,13 +48,15 @@ const tested = describe('Property', () => {
4348
});
4449

4550
it('reads non-existent object\'s property as null', async () => {
46-
await loadPromise;
51+
const loaded = await loadPromise;
52+
assert.strictEqual(loaded, true);
4753
const prop = new Property({ ...opts, name: 'awdaldaklwd23' });
4854
assert.strictEqual(prop.value, null);
4955
});
5056

5157
it('reads non-existent property as null', async () => {
52-
await loadPromise;
58+
const loaded = await loadPromise;
59+
assert.strictEqual(loaded, true);
5360
const prop = new Property({ ...opts, key: 'awdaldaklwd23' });
5461
assert.strictEqual(prop.value, null);
5562
});

test/view.test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ const methods = [
1919
const staticMethods = ['init', 'libs', 'plugins', 'style', 'update'];
2020

2121
const view = new View({ file: 'test.qml' });
22-
const loadPromise = new Promise((res) => view.on('load', () => res(true)));
23-
const texturePromise = new Promise((res) => view.on('reset', (id) => res(id)));
22+
const loadPromise = Promise.race([
23+
new Promise((res) => { setTimeout(() => res(false), 5000); }),
24+
new Promise((res) => view.on('load', () => res(true))),
25+
]);
26+
const texturePromise = Promise.race([
27+
new Promise((res) => { setTimeout(() => res(null), 5000); }),
28+
new Promise((res) => view.on('reset', (id) => res(id))),
29+
]);
30+
2431

2532
const tested = describe('Qml View', () => {
2633
it('has all static methods', () => {

0 commit comments

Comments
 (0)