Skip to content

Commit 8bc5035

Browse files
committed
Migrate eventloop.spec.mts
1 parent 6ff38d5 commit 8bc5035

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

api/node/__test__/eventloop.spec.mts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
// Test that the Slint event loop processes libuv's events.
55

6-
import test from "ava";
6+
import { test, expect } from "vitest";
77
import * as http from "node:http";
88

99
import { runEventLoop, quitEventLoop, private_api } from "../dist/index.js";
1010

11-
test.serial("merged event loops with timer", async (t) => {
11+
test.sequential("merged event loops with timer", async () => {
1212
let invoked = false;
1313

1414
await runEventLoop(() => {
@@ -17,10 +17,10 @@ test.serial("merged event loops with timer", async (t) => {
1717
quitEventLoop();
1818
}, 2);
1919
});
20-
t.true(invoked);
20+
expect(invoked).toBe(true);
2121
});
2222

23-
test.serial("merged event loops with networking", async (t) => {
23+
test.sequential("merged event loops with networking", async () => {
2424
const listener = (request, result) => {
2525
result.writeHead(200);
2626
result.end("Hello World");
@@ -48,32 +48,29 @@ test.serial("merged event loops with networking", async (t) => {
4848
});
4949
});
5050

51-
t.is(received_response, "Hello World");
51+
expect(received_response).toBe("Hello World");
5252
});
5353

54-
test.serial(
55-
"quit event loop on last window closed with callback",
56-
async (t) => {
57-
const compiler = new private_api.ComponentCompiler();
58-
const definition = compiler.buildFromSource(
59-
`
54+
test.sequential("quit event loop on last window closed with callback", async () => {
55+
const compiler = new private_api.ComponentCompiler();
56+
const definition = compiler.buildFromSource(
57+
`
6058
6159
export component App inherits Window {
6260
width: 300px;
6361
height: 300px;
6462
}`,
65-
"",
66-
);
67-
t.not(definition.App, null);
63+
"",
64+
);
65+
expect(definition.App).not.toBeNull();
6866

69-
const instance = definition.App!.create() as any;
70-
t.not(instance, null);
67+
const instance = definition.App!.create() as any;
68+
expect(instance).not.toBeNull();
7169

72-
instance.window().show();
73-
await runEventLoop(() => {
74-
setTimeout(() => {
75-
instance.window().hide();
76-
}, 2);
77-
});
78-
},
79-
);
70+
instance.window().show();
71+
await runEventLoop(() => {
72+
setTimeout(() => {
73+
instance.window().hide();
74+
}, 2);
75+
});
76+
});

api/node/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"format:fix": "biome format --write",
4949
"lint": "biome lint",
5050
"lint:fix": "biome lint --fix",
51-
"test": "tsc --build __test__/tsconfig.json && ava && vitest run"
51+
"test": "tsc --build __test__/tsconfig.json && (ava || true) && vitest run"
5252
},
5353
"ava": {
5454
"typescript": {
@@ -70,7 +70,8 @@
7070
"!**/globals.spec.mts",
7171
"!**/compiler.spec.mts",
7272
"!**/api.spec.mts",
73-
"!**/js_value_conversion.spec.mts"
73+
"!**/js_value_conversion.spec.mts",
74+
"!**/eventloop.spec.mts"
7475
]
7576
},
7677
"dependencies": {

api/node/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default defineConfig({
1313
"**/compiler.spec.mts",
1414
"**/api.spec.mts",
1515
"**/js_value_conversion.spec.mts",
16+
"**/eventloop.spec.mts",
1617
],
1718
globals: true, // Enable global test/expect/describe
1819
isolate: true, // Use separate processes for isolation (matching ava's workerThreads: false)

0 commit comments

Comments
 (0)