]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/completion/test_tsserver_completion_parsing.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / test / completion / test_tsserver_completion_parsing.vader
1 Before:
2   Save g:ale_completion_autoimport
3   Save g:ale_completion_tsserver_remove_warnings
4
5   let g:ale_completion_autoimport = v:true
6   let g:ale_completion_tsserver_remove_warnings = v:false
7
8 After:
9   Restore
10
11   unlet! b:ale_tsserver_completion_names
12
13 Execute(TypeScript completions responses should be parsed correctly):
14   AssertEqual [],
15   \ ale#completion#ParseTSServerCompletions({
16   \ 'body': [],
17   \})
18   AssertEqual
19   \ [
20   \   {
21   \     'word': 'foo',
22   \     'source': '/path/to/foo.ts',
23   \   },
24   \   {
25   \     'word': 'bar',
26   \     'source': '',
27   \   },
28   \   {
29   \     'word': 'baz',
30   \     'source': '',
31   \   }
32   \ ],
33   \ ale#completion#ParseTSServerCompletions({
34   \ 'body': [
35   \   {'name': 'foo', 'source': '/path/to/foo.ts'},
36   \   {'name': 'bar'},
37   \   {'name': 'baz'},
38   \ ],
39   \})
40
41 Execute(TypeScript completions responses should include warnings):
42   AssertEqual
43   \ [
44   \   {
45   \     'word': 'foo',
46   \     'source': '/path/to/foo.ts',
47   \   },
48   \   {
49   \     'word': 'bar',
50   \     'source': '',
51   \   },
52   \   {
53   \     'word': 'baz',
54   \     'source': '',
55   \   }
56   \ ],
57   \ ale#completion#ParseTSServerCompletions({
58   \ 'body': [
59   \   {'name': 'foo', 'source': '/path/to/foo.ts'},
60   \   {'name': 'bar', 'kind': 'warning'},
61   \   {'name': 'baz'},
62   \ ],
63   \})
64
65 Execute(TypeScript completions responses should not include warnings if excluded):
66   let g:ale_completion_tsserver_remove_warnings = 1
67   AssertEqual
68   \ [
69   \   {
70   \     'word': 'foo',
71   \     'source': '/path/to/foo.ts',
72   \   },
73   \   {
74   \     'word': 'baz',
75   \     'source': '',
76   \   }
77   \ ],
78   \ ale#completion#ParseTSServerCompletions({
79   \ 'body': [
80   \   {'name': 'foo', 'source': '/path/to/foo.ts'},
81   \   {'name': 'bar', 'kind': 'warning'},
82   \   {'name': 'baz'},
83   \ ],
84   \})
85
86 Execute(TypeScript completion details responses should be parsed correctly):
87   AssertEqual
88   \ [
89   \   {
90   \     'word': 'abc',
91   \     'menu': '(property) Foo.abc: number',
92   \     'info': '',
93   \     'kind': 'v',
94   \     'icase': 1,
95   \     'user_data': json_encode({'_ale_completion_item': 1}),
96   \     'dup': g:ale_completion_autoimport + 0,
97   \   },
98   \   {
99   \     'word': 'def',
100   \     'menu': '(property) Foo.def: number',
101   \     'info': 'foo bar baz',
102   \     'kind': 'v',
103   \     'icase': 1,
104   \     'user_data': json_encode({'_ale_completion_item': 1}),
105   \     'dup': g:ale_completion_autoimport + 0,
106   \   },
107   \   {
108   \     'word': 'ghi',
109   \     'menu': '(class) Foo',
110   \     'info': '',
111   \     'kind': 'v',
112   \     'icase': 1,
113   \     'user_data': json_encode({'_ale_completion_item': 1}),
114   \     'dup': g:ale_completion_autoimport + 0,
115   \   },
116   \ ],
117   \ ale#completion#ParseTSServerCompletionEntryDetails({
118   \ 'body': [
119   \   {
120   \     'name': 'abc',
121   \     'kind': 'parameterName',
122   \     'displayParts': [
123   \       {'text': '('},
124   \       {'text': 'property'},
125   \       {'text': ')'},
126   \       {'text': ' '},
127   \       {'text': 'Foo'},
128   \       {'text': '.'},
129   \       {'text': 'abc'},
130   \       {'text': ':'},
131   \       {'text': ' '},
132   \       {'text': 'number'},
133   \     ],
134   \   },
135   \   {
136   \     'name': 'def',
137   \     'kind': 'parameterName',
138   \     'displayParts': [
139   \       {'text': '('},
140   \       {'text': 'property'},
141   \       {'text': ')'},
142   \       {'text': ' '},
143   \       {'text': 'Foo'},
144   \       {'text': '.'},
145   \       {'text': 'def'},
146   \       {'text': ':'},
147   \       {'text': ' '},
148   \       {'text': 'number'},
149   \     ],
150   \     'documentation': [
151   \       {'text': 'foo'},
152   \       {'text': ' '},
153   \       {'text': 'bar'},
154   \       {'text': ' '},
155   \       {'text': 'baz'},
156   \     ],
157   \   },
158   \   {
159   \     'name': 'ghi',
160   \     'kind': 'className',
161   \     'displayParts': [
162   \       {'text': '('},
163   \       {'text': 'class'},
164   \       {'text': ')'},
165   \       {'text': ' '},
166   \       {'text': 'Foo'},
167   \     ],
168   \   },
169   \ ],
170   \})
171
172 Execute(Entries without details should be included in the responses):
173   let b:ale_tsserver_completion_names = [{
174   \  'word': 'xyz',
175   \  'source': '/path/to/xyz.ts',
176   \ }]
177
178   AssertEqual
179   \ [
180   \   {
181   \     'word': 'abc',
182   \     'menu': 'import { def } from "./Foo"; (property) Foo.abc: number',
183   \     'info': '',
184   \     'kind': 'v',
185   \     'icase': 1,
186   \     'user_data': json_encode({
187   \         '_ale_completion_item': 1,
188   \         'code_actions': [{
189   \             'description': 'import { def } from "./Foo";',
190   \             'changes': [],
191   \         }],
192   \     }),
193   \     'dup': g:ale_completion_autoimport + 0,
194   \   },
195   \   {
196   \     'word': 'def',
197   \     'menu': '(property) Foo.def: number',
198   \     'info': 'foo bar baz',
199   \     'kind': 'v',
200   \     'icase': 1,
201   \     'user_data': json_encode({'_ale_completion_item': 1}),
202   \     'dup': g:ale_completion_autoimport + 0,
203   \   },
204   \   {
205   \     'word': 'xyz',
206   \     'menu': '',
207   \     'info': '',
208   \     'kind': 'v',
209   \     'user_data': json_encode({'_ale_completion_item': 1}),
210   \     'icase': 1,
211   \   },
212   \ ],
213   \ ale#completion#ParseTSServerCompletionEntryDetails({
214   \ 'body': [
215   \   {
216   \     'name': 'abc',
217   \     'kind': 'parameterName',
218   \     'displayParts': [
219   \       {'text': '('},
220   \       {'text': 'property'},
221   \       {'text': ')'},
222   \       {'text': ' '},
223   \       {'text': 'Foo'},
224   \       {'text': '.'},
225   \       {'text': 'abc'},
226   \       {'text': ':'},
227   \       {'text': ' '},
228   \       {'text': 'number'},
229   \     ],
230   \     'codeActions': [{
231   \        'description': 'import { def } from "./Foo";',
232   \        'changes': [],
233   \     }],
234   \   },
235   \   {
236   \     'name': 'def',
237   \     'kind': 'parameterName',
238   \     'displayParts': [
239   \       {'text': '('},
240   \       {'text': 'property'},
241   \       {'text': ')'},
242   \       {'text': ' '},
243   \       {'text': 'Foo'},
244   \       {'text': '.'},
245   \       {'text': 'def'},
246   \       {'text': ':'},
247   \       {'text': ' '},
248   \       {'text': 'number'},
249   \     ],
250   \     'documentation': [
251   \       {'text': 'foo'},
252   \       {'text': ' '},
253   \       {'text': 'bar'},
254   \       {'text': ' '},
255   \       {'text': 'baz'},
256   \     ],
257   \   },
258   \ ],
259   \})
260
261 Execute(Default imports should be handled correctly):
262   AssertEqual
263   \ [
264   \   {
265   \     'word': 'abcd',
266   \     'menu': 'Import default ''abcd'' from module "./foo" (alias) const abcd: 3',
267   \     'info': '',
268   \     'kind': 't',
269   \     'icase': 1,
270   \     'user_data': json_encode({
271   \         '_ale_completion_item': 1,
272   \         'code_actions': [{
273   \             'description': 'Import default ''abcd'' from module "./foo"',
274   \             'changes': [],
275   \         }],
276   \     }),
277   \     'dup': g:ale_completion_autoimport + 0,
278   \   },
279   \ ],
280   \ ale#completion#ParseTSServerCompletionEntryDetails({
281   \   'body': [
282   \     {
283   \       'name': 'default',
284   \       'kind': 'alias',
285   \       'displayParts': [
286   \         {'kind': 'punctuation', 'text': '('},
287   \         {'kind': 'text', 'text': 'alias'},
288   \         {'kind': 'punctuation', 'text': ')'},
289   \         {'kind': 'space', 'text': ' '},
290   \         {'kind': 'keyword', 'text': 'const'},
291   \         {'kind': 'space', 'text': ' '},
292   \         {'kind': 'localName', 'text': 'abcd'},
293   \         {'kind': 'punctuation', 'text': ':'},
294   \         {'kind': 'space', 'text': ' '},
295   \         {'kind': 'stringLiteral', 'text': '3'},
296   \         {'kind': 'lineBreak', 'text': '^@'},
297   \         {'kind': 'keyword', 'text': 'export'},
298   \         {'kind': 'space', 'text': ' '},
299   \         {'kind': 'keyword', 'text': 'default'},
300   \         {'kind': 'space', 'text': ' '},
301   \         {'kind': 'aliasName', 'text': 'abcd'}
302   \       ],
303   \       'codeActions': [
304   \         {
305   \           'description': 'Import default ''abcd'' from module "./foo"',
306   \           'changes': [],
307   \         },
308   \       ],
309   \     },
310   \   ],
311   \ })