33
44// Test that the Slint event loop processes libuv's events.
55
6- import test from "ava " ;
6+ import { test , expect , afterEach } from "vitest " ;
77import * as http from "node:http" ;
88
99import { runEventLoop , quitEventLoop , private_api } from "../dist/index.js" ;
1010
11- test . serial ( "merged event loops with timer" , async ( t ) => {
11+ afterEach ( ( ) => {
12+ quitEventLoop ( ) ;
13+ } ) ;
14+
15+ test . sequential ( "merged event loops with timer" , async ( ) => {
1216 let invoked = false ;
1317
1418 await runEventLoop ( ( ) => {
@@ -17,10 +21,10 @@ test.serial("merged event loops with timer", async (t) => {
1721 quitEventLoop ( ) ;
1822 } , 2 ) ;
1923 } ) ;
20- t . true ( invoked ) ;
24+ expect ( invoked ) . toBe ( true ) ;
2125} ) ;
2226
23- test . serial ( "merged event loops with networking" , async ( t ) => {
27+ test . sequential ( "merged event loops with networking" , async ( ) => {
2428 const listener = ( request , result ) => {
2529 result . writeHead ( 200 ) ;
2630 result . end ( "Hello World" ) ;
@@ -48,32 +52,29 @@ test.serial("merged event loops with networking", async (t) => {
4852 } ) ;
4953 } ) ;
5054
51- t . is ( received_response , "Hello World" ) ;
55+ expect ( received_response ) . toBe ( "Hello World" ) ;
5256} ) ;
5357
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- `
58+ test . sequential ( "quit event loop on last window closed with callback" , async ( ) => {
59+ const compiler = new private_api . ComponentCompiler ( ) ;
60+ const definition = compiler . buildFromSource (
61+ `
6062
6163 export component App inherits Window {
6264 width: 300px;
6365 height: 300px;
6466 }` ,
65- "" ,
66- ) ;
67- t . not ( definition . App , null ) ;
67+ "" ,
68+ ) ;
69+ expect ( definition . App ) . not . toBeNull ( ) ;
6870
69- const instance = definition . App ! . create ( ) as any ;
70- t . not ( instance , null ) ;
71+ const instance = definition . App ! . create ( ) as any ;
72+ expect ( instance ) . not . toBeNull ( ) ;
7173
72- instance . window ( ) . show ( ) ;
73- await runEventLoop ( ( ) => {
74- setTimeout ( ( ) => {
75- instance . window ( ) . hide ( ) ;
76- } , 2 ) ;
77- } ) ;
78- } ,
79- ) ;
74+ instance . window ( ) . show ( ) ;
75+ await runEventLoop ( ( ) => {
76+ setTimeout ( ( ) => {
77+ instance . window ( ) . hide ( ) ;
78+ } , 2 ) ;
79+ } ) ;
80+ } ) ;
0 commit comments