Skip to content

Commit 6f7682c

Browse files
committed
🌿 improve tests for Denops.interrupted property
1 parent f9ab988 commit 6f7682c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

denops/@denops-private/denops_test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { BatchError, type Meta } from "jsr:@denops/core@^7.0.0";
22
import {
3+
assert,
34
assertEquals,
5+
assertFalse,
46
assertInstanceOf,
57
assertRejects,
68
assertStrictEquals,
@@ -29,15 +31,29 @@ Deno.test("DenopsImpl", async (t) => {
2931
call: () => unimplemented(),
3032
batch: () => unimplemented(),
3133
};
34+
const serviceInterrupt = new AbortController();
3235
const service: Service = {
3336
dispatch: () => unimplemented(),
3437
waitLoaded: () => unimplemented(),
35-
interrupted: new AbortController().signal,
38+
interrupted: serviceInterrupt.signal,
3639
};
3740
const denops = new DenopsImpl("dummy", meta, host, service);
3841

39-
await t.step("interrupted returns AbortSignal instance", () => {
40-
assertInstanceOf(denops.interrupted, AbortSignal);
42+
await t.step(".interrupted property", async (t) => {
43+
await t.step("returns AbortSignal instance", () => {
44+
assertInstanceOf(denops.interrupted, AbortSignal);
45+
});
46+
47+
await t.step("aborts when `Service.interrupted` aborts", () => {
48+
const signal = denops.interrupted;
49+
50+
assertFalse(signal.aborted);
51+
52+
serviceInterrupt.abort("test");
53+
54+
assert(signal.aborted);
55+
assertEquals(signal.reason, "test");
56+
});
4157
});
4258

4359
await t.step(".redraw()", async (t) => {

0 commit comments

Comments
 (0)