Skip to content

Commit 486f9a8

Browse files
authored
Merge pull request #18 from vim-denops/testable
Add tests for `variable` module as test writing example
2 parents 1defdb2 + 784c76c commit 486f9a8

File tree

4 files changed

+68
-8
lines changed

4 files changed

+68
-8
lines changed

.github/workflows/test.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: deno
22

33
env:
44
DENO_VERSION: 1.x
5+
DENOPS_PATH: "./denops.vim"
56

67
on:
78
schedule:
@@ -42,9 +43,38 @@ jobs:
4243

4344
steps:
4445
- uses: actions/checkout@v2
46+
- uses: actions/checkout@v2
47+
with:
48+
repository: "vim-denops/denops.vim"
49+
path: "denops.vim"
4550
- uses: denoland/setup-deno@main
4651
with:
4752
deno-version: ${{ env.DENO_VERSION }}
53+
- uses: rhysd/action-setup-vim@v1
54+
id: vim
55+
with:
56+
version: "v8.1.2424"
57+
- uses: rhysd/action-setup-vim@v1
58+
id: nvim
59+
with:
60+
neovim: true
61+
version: "v0.4.4"
62+
- name: Check Vim
63+
run: |
64+
echo ${DENOPS_TEST_VIM}
65+
${DENOPS_TEST_VIM} --version
66+
env:
67+
DENOPS_TEST_VIM: ${{ steps.vim.outputs.executable }}
68+
- name: Check Neovim
69+
run: |
70+
echo ${DENOPS_TEST_NVIM}
71+
${DENOPS_TEST_NVIM} --version
72+
env:
73+
DENOPS_TEST_NVIM: ${{ steps.nvim.outputs.executable }}
4874
- name: Test
4975
run: |
50-
deno test
76+
deno test --unstable -A
77+
env:
78+
DENOPS_TEST_VIM: ${{ steps.vim.outputs.executable }}
79+
DENOPS_TEST_NVIM: ${{ steps.nvim.outputs.executable }}
80+
timeout-minutes: 5

deps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ export * as fs from "https://deno.land/std@0.95.0/fs/mod.ts";
55
export type {
66
Context,
77
Dispatcher,
8-
} from "https://deno.land/x/denops_core@v0.13.0/mod.ts";
8+
} from "https://deno.land/x/denops_core@v0.16.0/mod.ts";
99
export {
1010
Denops,
1111
ensureArray,
1212
ensureNumber,
1313
ensureRecord,
1414
ensureString,
15-
} from "https://deno.land/x/denops_core@v0.13.0/mod.ts";
15+
} from "https://deno.land/x/denops_core@v0.16.0/mod.ts";

test.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

vim/variable_test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Denops } from "../deps.ts";
2+
import { assertEquals } from "../deps_test.ts";
3+
import * as variable from "./variable.ts";
4+
5+
Denops.test("getVar() return the value of the variable", async (denops) => {
6+
await denops.cmd("let g:denops_std_vim_variable_test = 'hello'");
7+
const result = await variable.getVar(
8+
denops,
9+
"g",
10+
"denops_std_vim_variable_test",
11+
);
12+
assertEquals(result, "hello");
13+
});
14+
15+
Denops.test("setVar() replace the value of the variable", async (denops) => {
16+
await denops.cmd("let g:denops_std_vim_variable_test = 'hello'");
17+
await variable.setVar(denops, "g", "denops_std_vim_variable_test", "world");
18+
const result = await variable.getVar(
19+
denops,
20+
"g",
21+
"denops_std_vim_variable_test",
22+
);
23+
assertEquals(result, "world");
24+
});
25+
26+
Denops.test("removeVar() remove the variable", async (denops) => {
27+
await denops.cmd("let g:denops_std_vim_variable_test = 'hello'");
28+
await variable.removeVar(denops, "g", "denops_std_vim_variable_test");
29+
const result = await variable.getVar(
30+
denops,
31+
"g",
32+
"denops_std_vim_variable_test",
33+
);
34+
assertEquals(result, null);
35+
});

0 commit comments

Comments
 (0)