|
1 |
| -import { assertEquals, test } from "../deps_test.ts"; |
2 |
| -import { getVar, removeVar, setVar } from "./helper.ts"; |
| 1 | +import { assertEquals, assertThrowsAsync, test } from "../deps_test.ts"; |
| 2 | +import { buffers, globals, tabpages, vim, windows } from "./helper.ts"; |
3 | 3 |
|
4 | 4 | test({
|
5 | 5 | mode: "any",
|
6 |
| - name: "getVar() return the value of the variable", |
| 6 | + name: "globals.get() return the value of the variable", |
7 | 7 | fn: async (denops) => {
|
8 | 8 | await denops.cmd("let g:denops_std_vim_variable_test = 'hello'");
|
9 |
| - const result = await getVar( |
| 9 | + const result = await globals.get( |
10 | 10 | denops,
|
11 |
| - "g", |
12 | 11 | "denops_std_vim_variable_test",
|
13 | 12 | );
|
14 | 13 | assertEquals(result, "hello");
|
15 | 14 | },
|
16 | 15 | });
|
17 |
| - |
18 | 16 | test({
|
19 | 17 | mode: "any",
|
20 |
| - name: "setVar() replace the value of the variable", |
| 18 | + name: "globals.set() replace the value of the variable", |
21 | 19 | fn: async (denops) => {
|
22 | 20 | await denops.cmd("let g:denops_std_vim_variable_test = 'hello'");
|
23 |
| - await setVar(denops, "g", "denops_std_vim_variable_test", "world"); |
24 |
| - const result = await getVar( |
| 21 | + await globals.set(denops, "denops_std_vim_variable_test", "world"); |
| 22 | + const result = await globals.get( |
25 | 23 | denops,
|
26 |
| - "g", |
27 | 24 | "denops_std_vim_variable_test",
|
28 | 25 | );
|
29 | 26 | assertEquals(result, "world");
|
30 | 27 | },
|
31 | 28 | });
|
32 |
| - |
33 | 29 | test({
|
34 | 30 | mode: "any",
|
35 |
| - name: "removeVar() remove the variable", |
| 31 | + name: "globals.remove() remove the variable", |
36 | 32 | fn: async (denops) => {
|
37 | 33 | await denops.cmd("let g:denops_std_vim_variable_test = 'hello'");
|
38 |
| - await removeVar(denops, "g", "denops_std_vim_variable_test"); |
39 |
| - const result = await getVar( |
| 34 | + await globals.remove(denops, "denops_std_vim_variable_test"); |
| 35 | + const result = await globals.get( |
| 36 | + denops, |
| 37 | + "denops_std_vim_variable_test", |
| 38 | + ); |
| 39 | + assertEquals(result, null); |
| 40 | + }, |
| 41 | +}); |
| 42 | + |
| 43 | +test({ |
| 44 | + mode: "any", |
| 45 | + name: "buffers.get() return the value of the variable", |
| 46 | + fn: async (denops) => { |
| 47 | + await denops.cmd("let b:denops_std_vim_variable_test = 'hello'"); |
| 48 | + const result = await buffers.get( |
| 49 | + denops, |
| 50 | + "denops_std_vim_variable_test", |
| 51 | + ); |
| 52 | + assertEquals(result, "hello"); |
| 53 | + }, |
| 54 | +}); |
| 55 | +test({ |
| 56 | + mode: "any", |
| 57 | + name: "buffers.set() replace the value of the variable", |
| 58 | + fn: async (denops) => { |
| 59 | + await denops.cmd("let b:denops_std_vim_variable_test = 'hello'"); |
| 60 | + await buffers.set(denops, "denops_std_vim_variable_test", "world"); |
| 61 | + const result = await buffers.get( |
| 62 | + denops, |
| 63 | + "denops_std_vim_variable_test", |
| 64 | + ); |
| 65 | + assertEquals(result, "world"); |
| 66 | + }, |
| 67 | +}); |
| 68 | +test({ |
| 69 | + mode: "any", |
| 70 | + name: "buffers.remove() remove the variable", |
| 71 | + fn: async (denops) => { |
| 72 | + await denops.cmd("let b:denops_std_vim_variable_test = 'hello'"); |
| 73 | + await buffers.remove(denops, "denops_std_vim_variable_test"); |
| 74 | + const result = await buffers.get( |
40 | 75 | denops,
|
41 |
| - "g", |
42 | 76 | "denops_std_vim_variable_test",
|
43 | 77 | );
|
44 | 78 | assertEquals(result, null);
|
45 | 79 | },
|
46 | 80 | });
|
| 81 | + |
| 82 | +test({ |
| 83 | + mode: "any", |
| 84 | + name: "windows.get() return the value of the variable", |
| 85 | + fn: async (denops) => { |
| 86 | + await denops.cmd("let w:denops_std_vim_variable_test = 'hello'"); |
| 87 | + const result = await windows.get( |
| 88 | + denops, |
| 89 | + "denops_std_vim_variable_test", |
| 90 | + ); |
| 91 | + assertEquals(result, "hello"); |
| 92 | + }, |
| 93 | +}); |
| 94 | +test({ |
| 95 | + mode: "any", |
| 96 | + name: "windows.set() replace the value of the variable", |
| 97 | + fn: async (denops) => { |
| 98 | + await denops.cmd("let w:denops_std_vim_variable_test = 'hello'"); |
| 99 | + await windows.set(denops, "denops_std_vim_variable_test", "world"); |
| 100 | + const result = await windows.get( |
| 101 | + denops, |
| 102 | + "denops_std_vim_variable_test", |
| 103 | + ); |
| 104 | + assertEquals(result, "world"); |
| 105 | + }, |
| 106 | +}); |
| 107 | +test({ |
| 108 | + mode: "any", |
| 109 | + name: "windows.remove() remove the variable", |
| 110 | + fn: async (denops) => { |
| 111 | + await denops.cmd("let w:denops_std_vim_variable_test = 'hello'"); |
| 112 | + await windows.remove(denops, "denops_std_vim_variable_test"); |
| 113 | + const result = await windows.get( |
| 114 | + denops, |
| 115 | + "denops_std_vim_variable_test", |
| 116 | + ); |
| 117 | + assertEquals(result, null); |
| 118 | + }, |
| 119 | +}); |
| 120 | + |
| 121 | +test({ |
| 122 | + mode: "any", |
| 123 | + name: "tabpages.get() return the value of the variable", |
| 124 | + fn: async (denops) => { |
| 125 | + await denops.cmd("let t:denops_std_vim_variable_test = 'hello'"); |
| 126 | + const result = await tabpages.get( |
| 127 | + denops, |
| 128 | + "denops_std_vim_variable_test", |
| 129 | + ); |
| 130 | + assertEquals(result, "hello"); |
| 131 | + }, |
| 132 | +}); |
| 133 | +test({ |
| 134 | + mode: "any", |
| 135 | + name: "tabpages.set() replace the value of the variable", |
| 136 | + fn: async (denops) => { |
| 137 | + await denops.cmd("let t:denops_std_vim_variable_test = 'hello'"); |
| 138 | + await tabpages.set(denops, "denops_std_vim_variable_test", "world"); |
| 139 | + const result = await tabpages.get( |
| 140 | + denops, |
| 141 | + "denops_std_vim_variable_test", |
| 142 | + ); |
| 143 | + assertEquals(result, "world"); |
| 144 | + }, |
| 145 | +}); |
| 146 | +test({ |
| 147 | + mode: "any", |
| 148 | + name: "tabpages.remove() remove the variable", |
| 149 | + fn: async (denops) => { |
| 150 | + await denops.cmd("let t:denops_std_vim_variable_test = 'hello'"); |
| 151 | + await tabpages.remove(denops, "denops_std_vim_variable_test"); |
| 152 | + const result = await tabpages.get( |
| 153 | + denops, |
| 154 | + "denops_std_vim_variable_test", |
| 155 | + ); |
| 156 | + assertEquals(result, null); |
| 157 | + }, |
| 158 | +}); |
| 159 | + |
| 160 | +test({ |
| 161 | + mode: "any", |
| 162 | + name: "vim.get() return the value of the variable", |
| 163 | + fn: async (denops) => { |
| 164 | + await denops.cmd("let v:errors = ['hello']"); |
| 165 | + const result = await vim.get( |
| 166 | + denops, |
| 167 | + "errors", |
| 168 | + ); |
| 169 | + assertEquals(result, ["hello"]); |
| 170 | + }, |
| 171 | +}); |
| 172 | +test({ |
| 173 | + mode: "any", |
| 174 | + name: "vim.set() replace the value of the variable", |
| 175 | + fn: async (denops) => { |
| 176 | + await denops.cmd("let v:errors = ['hello']"); |
| 177 | + await vim.set(denops, "errors", ["world"]); |
| 178 | + const result = await vim.get( |
| 179 | + denops, |
| 180 | + "errors", |
| 181 | + ); |
| 182 | + assertEquals(result, ["world"]); |
| 183 | + }, |
| 184 | +}); |
| 185 | +test({ |
| 186 | + mode: "any", |
| 187 | + name: "vim.remove() throws error", |
| 188 | + fn: async (denops) => { |
| 189 | + await assertThrowsAsync( |
| 190 | + async () => { |
| 191 | + await vim.remove(denops, "errors"); |
| 192 | + }, |
| 193 | + undefined, |
| 194 | + "Vim variables", |
| 195 | + ); |
| 196 | + }, |
| 197 | +}); |
0 commit comments