Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions denops/@denops-private/cli_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Deno.test("main()", async (t) => {
);

await t.step("and the worker stream is closed", async (t) => {
fakeWorker.onmessage(new MessageEvent("message", { data: null }));
fakeWorker.onmessage!(new MessageEvent("message", { data: null }));
await delay(0);

await t.step("calls Worker.terminate()", () => {
Expand Down Expand Up @@ -453,7 +453,7 @@ Deno.test("main()", async (t) => {
assertSpyCalls(globalThis_Worker, 1);
fakeTcpListener.close();

fakeWorker.onmessage(new MessageEvent("message", { data: null }));
fakeWorker.onmessage!(new MessageEvent("message", { data: null }));
await delay(0);

await t.step("calls Worker.terminate()", () => {
Expand Down Expand Up @@ -557,7 +557,7 @@ Deno.test("main()", async (t) => {
await delay(0);

await t.step("and the worker stream is closed", async (t) => {
fakeWorker.onmessage(new MessageEvent("message", { data: null }));
fakeWorker.onmessage!(new MessageEvent("message", { data: null }));
await delay(0);

await t.step("outputs error logs", () => {
Expand Down
9 changes: 7 additions & 2 deletions denops/@denops-private/worker_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ for (const { host, mode } of matrix) {
throw error;
});

await delay(0);
assertEquals(consoleStub.error.firstCall.args, [
// NOTE: The unhandledrejection event dispatch timing varies across
// platforms and Deno versions. Poll until console.error is called.
const deadline = Date.now() + 5000;
while (!consoleStub.error.firstCall && Date.now() < deadline) {
await delay(10);
}
assertEquals(consoleStub.error.firstCall?.args, [
"Unhandled rejection:",
error,
]);
Expand Down
6 changes: 5 additions & 1 deletion tests/denops/testutil/mock_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ type MethodKeyOf<T extends AnyRecord> = ({
[K in keyof T]: T[K] extends AnyFn ? K : never;
})[keyof T];

type NullableMethodKeyOf<T extends AnyRecord> = ({
[K in keyof T]: T[K] extends AnyFn | null ? K : never;
})[keyof T];

type GetterKeyOf<T extends AnyRecord> = ({
[K in keyof T]: T[K] extends AnyFn ? never : K;
})[keyof T];
Expand Down Expand Up @@ -337,7 +341,7 @@ Deno.test("createFakeWorker()", async (t) => {
"removeEventListener",
"dispatchEvent",
"terminate",
] as const satisfies readonly MethodKeyOf<Worker>[];
] as const satisfies readonly NullableMethodKeyOf<Worker>[];
for (const key of unimplementedMethods) {
await t.step(`.${key}()`, () => {
assertThrows(() => (worker[key] as AnyFn)(), Error, "Unimplemented");
Expand Down
2 changes: 1 addition & 1 deletion tests/denops/testutil/with.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function withVim<T>(
"-c",
"visual", // Go to Normal mode
"-c",
"set columns=9999", // Avoid unwilling output newline
"set columns=9999 shortmess-=T", // Avoid unwilling output newline/truncation
...commands.flatMap((c) => ["-c", c]),
];
return withProcess(cmd, args, { verbose: conf.verbose, ...options });
Expand Down
Loading