Skip to content

Commit c94ebed

Browse files
committed
🌿 Merge tests into single test
`test` spawn Vim/Neovim and that cause timeout on Windows so we decided to merge individual tests into single `test` with `t.step()`.
1 parent 96c7f91 commit c94ebed

File tree

17 files changed

+2772
-2531
lines changed

17 files changed

+2772
-2531
lines changed

denops_std/anonymous/mod_test.ts

Lines changed: 81 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,91 +7,92 @@ import * as anonymous from "./mod.ts";
77

88
test({
99
mode: "all",
10-
name: "add() registers anonymous functions",
11-
fn: async (denops) => {
12-
const ids = anonymous.add(
13-
denops,
14-
() => Promise.resolve("0"),
15-
() => Promise.resolve("1"),
16-
() => Promise.resolve("2"),
17-
);
18-
assertEquals(await denops.dispatch(denops.name, ids[0]), "0");
19-
assertEquals(await denops.dispatch(denops.name, ids[1]), "1");
20-
assertEquals(await denops.dispatch(denops.name, ids[2]), "2");
21-
assertEquals(await denops.dispatch(denops.name, ids[0]), "0");
22-
assertEquals(await denops.dispatch(denops.name, ids[1]), "1");
23-
assertEquals(await denops.dispatch(denops.name, ids[2]), "2");
24-
},
25-
});
10+
name: "anonymous",
11+
fn: async (denops, t) => {
12+
await t.step({
13+
name: "add() registers anonymous functions",
14+
fn: async () => {
15+
const ids = anonymous.add(
16+
denops,
17+
() => Promise.resolve("0"),
18+
() => Promise.resolve("1"),
19+
() => Promise.resolve("2"),
20+
);
21+
assertEquals(await denops.dispatch(denops.name, ids[0]), "0");
22+
assertEquals(await denops.dispatch(denops.name, ids[1]), "1");
23+
assertEquals(await denops.dispatch(denops.name, ids[2]), "2");
24+
assertEquals(await denops.dispatch(denops.name, ids[0]), "0");
25+
assertEquals(await denops.dispatch(denops.name, ids[1]), "1");
26+
assertEquals(await denops.dispatch(denops.name, ids[2]), "2");
27+
},
28+
});
2629

27-
test({
28-
mode: "all",
29-
name: "once() registers oneshot anonymous functions",
30-
fn: async (denops) => {
31-
const ids = anonymous.once(
32-
denops,
33-
() => Promise.resolve("0"),
34-
() => Promise.resolve("1"),
35-
() => Promise.resolve("2"),
36-
);
37-
assertEquals(await denops.dispatch(denops.name, ids[0]), "0");
38-
assertEquals(await denops.dispatch(denops.name, ids[1]), "1");
39-
assertEquals(await denops.dispatch(denops.name, ids[2]), "2");
30+
await t.step({
31+
name: "once() registers oneshot anonymous functions",
32+
fn: async () => {
33+
const ids = anonymous.once(
34+
denops,
35+
() => Promise.resolve("0"),
36+
() => Promise.resolve("1"),
37+
() => Promise.resolve("2"),
38+
);
39+
assertEquals(await denops.dispatch(denops.name, ids[0]), "0");
40+
assertEquals(await denops.dispatch(denops.name, ids[1]), "1");
41+
assertEquals(await denops.dispatch(denops.name, ids[2]), "2");
4042

41-
// The method will be removed
42-
await assertRejects(
43-
async () => {
44-
await denops.dispatch(denops.name, ids[0]);
45-
},
46-
`No method '${ids[0]}' exists`,
47-
);
48-
await assertRejects(
49-
async () => {
50-
await denops.dispatch(denops.name, ids[1]);
51-
},
52-
`No method '${ids[1]}' exists`,
53-
);
54-
await assertRejects(
55-
async () => {
56-
await denops.dispatch(denops.name, ids[2]);
43+
// The method will be removed
44+
await assertRejects(
45+
async () => {
46+
await denops.dispatch(denops.name, ids[0]);
47+
},
48+
`No method '${ids[0]}' exists`,
49+
);
50+
await assertRejects(
51+
async () => {
52+
await denops.dispatch(denops.name, ids[1]);
53+
},
54+
`No method '${ids[1]}' exists`,
55+
);
56+
await assertRejects(
57+
async () => {
58+
await denops.dispatch(denops.name, ids[2]);
59+
},
60+
`No method '${ids[2]}' exists`,
61+
);
5762
},
58-
`No method '${ids[2]}' exists`,
59-
);
60-
},
61-
prelude: ["let g:denops#enable_workaround_vim_before_8_2_3081 = 1"],
62-
});
63+
});
6364

64-
test({
65-
mode: "all",
66-
name: "remove() unregisters anonymous functions identified by ids",
67-
fn: async (denops) => {
68-
const ids = anonymous.add(
69-
denops,
70-
() => Promise.resolve("0"),
71-
() => Promise.resolve("1"),
72-
() => Promise.resolve("2"),
73-
);
74-
assertEquals(anonymous.remove(denops, ...ids), [true, true, true]);
65+
await t.step({
66+
name: "remove() unregisters anonymous functions identified by ids",
67+
fn: async () => {
68+
const ids = anonymous.add(
69+
denops,
70+
() => Promise.resolve("0"),
71+
() => Promise.resolve("1"),
72+
() => Promise.resolve("2"),
73+
);
74+
assertEquals(anonymous.remove(denops, ...ids), [true, true, true]);
7575

76-
// The method is removed
77-
await assertRejects(
78-
async () => {
79-
await denops.dispatch(denops.name, ids[0]);
80-
},
81-
`No method '${ids[0]}' exists`,
82-
);
83-
await assertRejects(
84-
async () => {
85-
await denops.dispatch(denops.name, ids[1]);
86-
},
87-
`No method '${ids[1]}' exists`,
88-
);
89-
await assertRejects(
90-
async () => {
91-
await denops.dispatch(denops.name, ids[2]);
76+
// The method is removed
77+
await assertRejects(
78+
async () => {
79+
await denops.dispatch(denops.name, ids[0]);
80+
},
81+
`No method '${ids[0]}' exists`,
82+
);
83+
await assertRejects(
84+
async () => {
85+
await denops.dispatch(denops.name, ids[1]);
86+
},
87+
`No method '${ids[1]}' exists`,
88+
);
89+
await assertRejects(
90+
async () => {
91+
await denops.dispatch(denops.name, ids[2]);
92+
},
93+
`No method '${ids[2]}' exists`,
94+
);
9295
},
93-
`No method '${ids[2]}' exists`,
94-
);
96+
});
9597
},
96-
prelude: ["let g:denops#enable_workaround_vim_before_8_2_3081 = 1"],
9798
});

0 commit comments

Comments
 (0)