summaryrefslogtreecommitdiff
path: root/test/fixers
diff options
context:
space:
mode:
authorrhysd <lin90162@yahoo.co.jp>2018-01-24 10:36:02 +0000
committerw0rp <devw0rp@gmail.com>2018-01-24 10:36:31 +0000
commitb28a6ddbe4cf573ea993288a6ad4db569d535adf (patch)
treeb1ed7770efb8122d85921aa43c18f069819eeeaa /test/fixers
parentd562d531024a2a2210fdf08594639a0b068bacce (diff)
downloadale-b28a6ddbe4cf573ea993288a6ad4db569d535adf.zip
Support fixing JSON files with fixjson
Diffstat (limited to 'test/fixers')
-rw-r--r--test/fixers/test_fixjson_fixer_callback.vader50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/fixers/test_fixjson_fixer_callback.vader b/test/fixers/test_fixjson_fixer_callback.vader
new file mode 100644
index 00000000..1a3bdcfc
--- /dev/null
+++ b/test/fixers/test_fixjson_fixer_callback.vader
@@ -0,0 +1,50 @@
+Before:
+ Save g:ale_json_fixjson_executable
+ Save g:ale_json_fixjson_options
+
+ let g:ale_json_fixjson_executable = '/path/to/fixjson'
+ let g:ale_json_fixjson_options = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ Restore
+
+Execute(The fixjson callback should return the correct default command):
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('/path/to/fixjson')
+ \ . ' --stdin-filename '
+ \ . ale#Escape(bufname(bufnr('')))
+ \ },
+ \ ale#fixers#fixjson#Fix(bufnr(''))
+
+Execute(The fixjson callback should set the buffer name as file name):
+ call ale#test#SetFilename('../json_files/testfile.json')
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('/path/to/fixjson')
+ \ . ' --stdin-filename '
+ \ . ale#Escape(bufname(bufnr('')))
+ \ },
+ \ ale#fixers#fixjson#Fix(bufnr(''))
+
+ AssertNotEqual
+ \ stridx(
+ \ ale#fixers#fixjson#Fix(bufnr('')).command,
+ \ 'testfile.json',
+ \ ),
+ \ -1
+
+Execute(The fixjson callback should include additional options):
+ let g:ale_json_fixjson_options = '-i 2'
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('/path/to/fixjson')
+ \ . ' --stdin-filename '
+ \ . ale#Escape(bufname(bufnr('')))
+ \ . ' -i 2'
+ \ },
+ \ ale#fixers#fixjson#Fix(bufnr(''))