]> git.madduck.net Git - etc/vim.git/blob - test/lsp/utils/workspace_config.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 / utils / workspace_config.vimspec
1 Describe lsp#utils#workspace_config
2
3     Describe lsp#utils#workspace_config#get
4         It should return the workspace config, when it is a dict
5             let l:name = 'Unit Test Server'
6
7             call lsp#register_server({
8                 \     'name': l:name,
9                 \     'workspace_config': {
10                 \         'a': {
11                 \             'a1': v:true,
12                 \             'a2': {
13                 \                 'a21': 'disabled',
14                 \             },
15                 \         },
16                 \         'b': 'path/to/file',
17                 \     }
18                 \ })
19
20             let l:config = lsp#utils#workspace_config#get(l:name)
21
22             Assert Equals(l:config['a']['a1'], v:true)
23             Assert Equals(l:config['a']['a2']['a21'], 'disabled')
24             Assert Equals(l:config['b'], 'path/to/file')
25         end
26
27         It should return the workspace config, produced by a callback
28             let l:name = 'Unit Test Server'
29
30             let l:callResult = {}
31
32             call lsp#register_server({
33                 \     'name': l:name,
34                 \     'workspace_config': {server_info->l:callResult},
35                 \ })
36
37             let l:config = lsp#utils#workspace_config#get(l:name)
38             Assert Equals(l:config, {})
39
40             let l:callResult = {
41                 \     'a': {
42                 \         'a1': v:true,
43                 \         'a2': {
44                 \             'a21': 'disabled',
45                 \         },
46                 \     },
47                 \     'b': 'path/to/file'
48                 \ }
49
50             let l:config = lsp#utils#workspace_config#get(l:name)
51             Assert Equals(l:config['a']['a1'], v:true)
52             Assert Equals(l:config['a']['a2']['a21'], 'disabled')
53             Assert Equals(l:config['b'], 'path/to/file')
54         end
55     End
56
57     Describe lsp#utils#workspace_config#project
58         It should return a projection of a dictionary
59             let l:config = {
60                 \     'a': {
61                 \         'a1': v:true,
62                 \         'a2': {
63                 \             'a21': 'disabled',
64                 \         },
65                 \     },
66                 \     'b': 'path/to/file',
67                 \ }
68
69             let l:config_a_a1 = lsp#utils#workspace_config#projection(
70                 \     l:config,
71                 \     { 'section': 'a.a1' },
72                 \ )
73             let l:config_a_a2_a21 = lsp#utils#workspace_config#projection(
74                 \     l:config,
75                 \     { 'section': 'a.a2.a21' },
76                 \ )
77             let l:config_b = lsp#utils#workspace_config#projection(
78                 \     l:config,
79                 \     { 'section': 'b' },
80                 \ )
81             let l:config_c = lsp#utils#workspace_config#projection(
82                 \     l:config,
83                 \     { 'section': 'c' },
84                 \ )
85
86             Assert Equals(l:config_a_a1, v:true)
87             Assert Equals(l:config_a_a2_a21, 'disabled')
88             Assert Equals(l:config_b, 'path/to/file')
89             Assert Equals(l:config_c, v:null)
90         end
91     End
92
93     Describe lsp#utils#workspace_config#get_value
94         It should return a projection of the workspace config, when it is a dict
95             let l:name = 'Unit Test Server'
96
97             call lsp#register_server({
98                 \     'name': l:name,
99                 \     'workspace_config': {
100                 \         'a': {
101                 \             'a1': v:true,
102                 \             'a2': {
103                 \                 'a21': 'disabled',
104                 \             },
105                 \          },
106                 \          'b': "path/to/file",
107                 \     }
108                 \ })
109
110             let l:config_a_a1 = lsp#utils#workspace_config#get_value(
111                 \     l:name,
112                 \     { 'section': 'a.a1' },
113                 \ )
114             let l:config_a_a2_a21 = lsp#utils#workspace_config#get_value(
115                 \     l:name,
116                 \     { 'section': 'a.a2.a21' },
117                 \ )
118             let l:config_b = lsp#utils#workspace_config#get_value(
119                 \     l:name,
120                 \     { 'section': 'b' },
121                 \ )
122             let l:config_c = lsp#utils#workspace_config#get_value(
123                 \     l:name,
124                 \     { 'section': 'c' },
125                 \ )
126
127             Assert Equals(l:config_a_a1, v:true)
128             Assert Equals(l:config_a_a2_a21, 'disabled')
129             Assert Equals(l:config_b, 'path/to/file')
130             Assert Equals(l:config_c, v:null)
131         end
132
133         It should return a projection of the workspace config, produced by a callback
134             let l:name = 'Unit Test Server'
135
136             let l:callResult = {}
137
138             call lsp#register_server({
139                 \     'name': l:name,
140                 \     'workspace_config': {server_info->l:callResult},
141                 \ })
142
143             let l:config = lsp#utils#workspace_config#get_value(
144                 \     l:name,
145                 \     { 'section': '' },
146                 \ )
147             Assert Equals(l:config, {})
148
149             let l:callResult = {
150                 \     'a': {
151                 \         'a1': v:true,
152                 \         'a2': {
153                 \             'a21': 'disabled',
154                 \         },
155                 \      },
156                 \      'b': "path/to/file",
157                 \ }
158
159             let l:config_a_a1 = lsp#utils#workspace_config#get_value(
160                 \     l:name,
161                 \     { 'section': 'a.a1' },
162                 \ )
163             let l:config_a_a2_a21 = lsp#utils#workspace_config#get_value(
164                 \     l:name,
165                 \     { 'section': 'a.a2.a21' },
166                 \ )
167             let l:config_b = lsp#utils#workspace_config#get_value(
168                 \     l:name,
169                 \     { 'section': 'b' },
170                 \ )
171             let l:config_c = lsp#utils#workspace_config#get_value(
172                 \     l:name,
173                 \     { 'section': 'c' },
174                 \ )
175
176             Assert Equals(l:config_a_a1, v:true)
177             Assert Equals(l:config_a_a2_a21, 'disabled')
178             Assert Equals(l:config_b, 'path/to/file')
179             Assert Equals(l:config_c, v:null)
180         end
181     End
182 End
183