Skip to content

Commit 08c36d2

Browse files
Add unit test target for JavaScriptEventLoopTestSupport
1 parent 28bb7f2 commit 08c36d2

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

Diff for: Package.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ let package = Package(
3131
name: "JavaScriptEventLoopTestSupport",
3232
dependencies: [
3333
"_CJavaScriptEventLoopTestSupport",
34-
.product(name: "JavaScriptEventLoop", package: "JavaScriptKit"),
34+
"JavaScriptEventLoop",
3535
]
3636
),
3737
.target(name: "_CJavaScriptEventLoopTestSupport"),
38+
.testTarget(
39+
name: "JavaScriptEventLoopTestSupportTests",
40+
dependencies: [
41+
"JavaScriptKit",
42+
"JavaScriptEventLoopTestSupport"
43+
]
44+
),
3845
]
3946
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import XCTest
2+
import JavaScriptKit
3+
4+
final class JavaScriptEventLoopTestSupportTests: XCTestCase {
5+
func testAwaitMicrotask() async {
6+
let _: () = await withCheckedContinuation { cont in
7+
JSObject.global.queueMicrotask.function!(
8+
JSOneshotClosure { _ in
9+
cont.resume(returning: ())
10+
return .undefined
11+
}
12+
)
13+
}
14+
}
15+
}

Diff for: scripts/test-harness.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Error.stackTraceLimit = Infinity;
2+
3+
const { startWasiTask, WASI } = require("../IntegrationTests/lib");
4+
5+
const handleExitOrError = (error) => {
6+
console.log(error);
7+
process.exit(1);
8+
}
9+
10+
startWasiTask(process.argv[2]).catch(handleExitOrError);

0 commit comments

Comments
 (0)