Skip to content

Commit 7648a1e

Browse files
committed
🌿 fix flaky test
1 parent e88220a commit 7648a1e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tests/denops/runtime/functions/denops/interrupt_test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ testHost({
4343
(await host.call("eval", "g:__test_denops_events") as string[])
4444
.includes("DenopsPluginPost:dummy")
4545
);
46-
await host.call("execute", [
47-
"let g:__test_denops_events = []",
48-
], "");
4946

5047
await t.step("returns immediately", async () => {
48+
await host.call("execute", [
49+
"let g:__test_denops_events = []",
50+
], "");
51+
5152
await host.call("denops#interrupt");
53+
54+
assertEquals(await host.call("eval", "g:__test_denops_events"), []);
5255
});
5356

5457
await t.step("sends signal to the plugin", async () => {

tests/denops/testdata/dummy_interrupt_plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import type { Entrypoint } from "jsr:@denops/core@^7.0.0";
2+
import { delay } from "jsr:@std/async@^1.0.1/delay";
23

34
export const main: Entrypoint = (denops) => {
45
function reset(): void {
56
const signal = denops.interrupted;
67
signal?.addEventListener("abort", async () => {
8+
await delay(100);
79
await denops.cmd(
810
`doautocmd <nomodeline> User DummyInterruptPlugin:Interrupted:${signal.reason}`,
911
);

0 commit comments

Comments
 (0)