-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathinvalidLaunch.test.js
More file actions
55 lines (43 loc) · 1.5 KB
/
Copy pathinvalidLaunch.test.js
File metadata and controls
55 lines (43 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { describe, expect, test } from "vitest";
import { java } from "../testHelpers";
describe("invalidLaunch", () => {
test("failedLaunch", () => {
expect(java.isJvmCreated()).toBeFalsy();
java.asyncOptions = {
syncSuffix: "Sync",
asyncSuffix: "",
};
// First show that if asyncOptions.promisify is undefined, using the promise variant of ensureJvm throws an error.
expect(() => {
java.ensureJvm();
}).toThrow(/requires its one argument to be a callback function/);
expect(java.isJvmCreated()).toBeFalsy();
});
test("callbackNotAFunction", () => {
expect(java.isJvmCreated()).toBeFalsy();
java.asyncOptions = {
syncSuffix: "",
promiseSuffix: "P",
promisify: require("when/node").lift, // https://github.com/cujojs/when
};
expect(() => {
java.ensureJvm("foo");
}).toThrow(/requires its one argument to be a callback function/);
expect(java.isJvmCreated()).toBeFalsy();
});
test("jvmCanStillBeLaunched", async () => {
// None of the previous tests should have caused the JVM to be created, so it should still be possible to create one.
expect(java.isJvmCreated()).toBeFalsy();
java.asyncOptions = {
syncSuffix: "",
promiseSuffix: "P",
promisify: require("when/node").lift, // https://github.com/cujojs/when
};
await new Promise((resolve) => {
java.ensureJvm().done(function () {
expect(java.isJvmCreated()).toBeTruthy();
resolve();
});
});
});
});