Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌿 add/improve tests for interrupt #422

Merged
merged 7 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions tests/denops/runtime/functions/denops/interrupt_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ testHost({
(await host.call("eval", "g:__test_denops_events") as string[])
.includes("DenopsPluginPost:dummy")
);
await host.call("execute", [
"let g:__test_denops_events = []",
], "");

await t.step("returns immediately", async () => {
await host.call("execute", [
"let g:__test_denops_events = []",
], "");

await host.call("denops#interrupt");

assertEquals(await host.call("eval", "g:__test_denops_events"), []);
Milly marked this conversation as resolved.
Show resolved Hide resolved
});

await t.step("sends signal to the plugin", async () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/denops/testdata/dummy_interrupt_plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Entrypoint } from "jsr:@denops/core@^7.0.0";
import { delay } from "jsr:@std/async@^1.0.1/delay";

export const main: Entrypoint = (denops) => {
function reset(): void {
const signal = denops.interrupted;
signal?.addEventListener("abort", async () => {
await delay(100);
Milly marked this conversation as resolved.
Show resolved Hide resolved
await denops.cmd(
`doautocmd <nomodeline> User DummyInterruptPlugin:Interrupted:${signal.reason}`,
);
Expand Down
Loading