]> git.madduck.net Git - etc/vim.git/blob - test/lsp/ui/vim/code_lens.vimspec

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:

Squashed '.vim/bundle/vim-lsp/' content from commit 04428c92
[etc/vim.git] / test / lsp / ui / vim / code_lens.vimspec
1 Describe lsp#uivim#code_lens
2     Describe lsp#ui#vim#code_lens#_get_subtitle
3         It should generate subtitle from response of rust-analyzer
4             " Example response of Code Lens extracted from #1118
5             let item = {
6             \     'codelens': {
7             \         'command': {
8             \             'arguments': [
9             \                 {
10             \                      'args': {
11             \                           'cargoArgs': ['test', '--package', 'tmp', '--lib'],
12             \                           'cargoExtraArgs': [],
13             \                           'executableArgs': ['tests::it_works', '--exact', '--nocapture'],
14             \                           'overrideCargo': v:null,
15             \                           'workspaceRoot': '/tmp'
16             \                      },
17             \                      'kind': 'cargo',
18             \                      'label': 'test tests::it_works',
19             \                      'location': {
20             \                           'targetRange': {'end': {'character': 5, 'line': 14}, 'start': {'character': 4, 'line': 11}},
21             \                           'targetSelectionRange': {'end': {'character': 15, 'line': 12}, 'start': {'character': 7, 'line': 12}},
22             \                           'targetUri': 'file:////tmp/src/lib.rs'
23             \                       }
24             \                 }
25             \             ],
26             \             'command': 'rust-analyzer.runSingle',
27             \             'title': '▶︎ Run Test'
28             \         },
29             \         'range': {'end': {'character': 5, 'line': 14}, 'start': {'character': 4, 'line': 11}}
30             \     },
31             \     'server': 'rust-analyzer'
32             \ }
33
34             let subtitle = lsp#ui#vim#code_lens#_get_subtitle(item)
35             Assert Equals(subtitle, ': test tests::it_works')
36         End
37
38         It should generate subtitle from multiple labels of command arguments
39             let item = {
40             \     'codelens': {
41             \         'command': {
42             \             'arguments': [
43             \                 {
44             \                      'args': {},
45             \                      'kind': 'kind1',
46             \                      'label': 'do command1',
47             \                      'location': {}
48             \                 },
49             \                 {
50             \                      'args': {},
51             \                      'kind': 'kind2',
52             \                      'label': 'do command2',
53             \                      'location': {}
54             \                 }
55             \             ],
56             \             'command': 'server.someCommand',
57             \             'title': 'lens title'
58             \         },
59             \         'range': {'end': {'character': 5, 'line': 14}, 'start': {'character': 4, 'line': 11}}
60             \     },
61             \     'server': 'rust-analyzer'
62             \ }
63
64             let subtitle = lsp#ui#vim#code_lens#_get_subtitle(item)
65             Assert Equals(subtitle, ': do command1 > do command2')
66         End
67
68         It should return empty string when 'arguments' field is not found
69             let item = {
70             \     'codelens': {
71             \         'command': {
72             \             'command': 'server.someCommand',
73             \             'title': 'lens title'
74             \         },
75             \         'range': {'end': {'character': 5, 'line': 14}, 'start': {'character': 4, 'line': 11}}
76             \     },
77             \     'server': 'rust-analyzer'
78             \ }
79
80             let subtitle = lsp#ui#vim#code_lens#_get_subtitle(item)
81             Assert Equals(subtitle, '')
82         End
83
84         It should return empty string when 'arguments' field is not an object
85             let item = {
86             \     'codelens': {
87             \         'command': {
88             \             'arguments': [
89             \                 'command1',
90             \                 'command2',
91             \                 'command3'
92             \             ],
93             \             'command': 'server.someCommand',
94             \             'title': 'lens title'
95             \         },
96             \         'range': {'end': {'character': 5, 'line': 14}, 'start': {'character': 4, 'line': 11}}
97             \     },
98             \     'server': 'rust-analyzer'
99             \ }
100
101             let subtitle = lsp#ui#vim#code_lens#_get_subtitle(item)
102             Assert Equals(subtitle, '')
103         End
104
105         It should return empty string when at least one of elements in 'arguments' field does not have 'label' field
106             let item = {
107             \     'codelens': {
108             \         'command': {
109             \             'arguments': [
110             \                 {
111             \                      'args': {},
112             \                      'kind': 'kind1',
113             \                      'label': 'do command1',
114             \                      'location': {}
115             \                 },
116             \                 {
117             \                      'args': {},
118             \                      'kind': 'kind2',
119             \                      'location': {}
120             \                 }
121             \             ],
122             \             'command': 'server.someCommand',
123             \             'title': 'lens title'
124             \         },
125             \         'range': {'end': {'character': 5, 'line': 14}, 'start': {'character': 4, 'line': 11}}
126             \     },
127             \     'server': 'rust-analyzer'
128             \ }
129
130             let subtitle = lsp#ui#vim#code_lens#_get_subtitle(item)
131             Assert Equals(subtitle, '')
132         End
133     End
134 End