summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-13 10:36:38 +0000
committerw0rp <devw0rp@gmail.com>2017-02-13 10:36:38 +0000
commit5cdd1498b459403c7e54a4dd45f2f14b97969544 (patch)
treec93e54b0dbbd539428ff383474b8344544582bbd /test
parent3aa1d57b5715b18f1544d36a3101ff45a6a86239 (diff)
downloadale-5cdd1498b459403c7e54a4dd45f2f14b97969544.zip
#283 Fix linting buffers with no filename, by creating a filename with a guess for the file extension
Diffstat (limited to 'test')
-rw-r--r--test/test_filetype_mapping.vader29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test_filetype_mapping.vader b/test/test_filetype_mapping.vader
new file mode 100644
index 00000000..2d72491d
--- /dev/null
+++ b/test/test_filetype_mapping.vader
@@ -0,0 +1,29 @@
+Before:
+ augroup TestFiletypeGroup
+ autocmd!
+ autocmd BufEnter,BufRead *.x setf xfiletype
+ autocmd BufEnter,BufRead *.y set filetype=yfiletype
+ autocmd BufEnter,BufRead *.z setlocal filetype=zfiletype
+ autocmd BufEnter,BufRead *.jsx set filetype=javascript.jsx
+ augroup END
+
+After:
+ unlet! g:map
+ augroup TestFiletypeGroup
+ autocmd!
+ augroup END
+ augroup! TestFiletypeGroup
+
+Execute(ALE should parse autocmd filetypes correctly):
+ let g:map = ale#filetypes#LoadExtensionMap()
+
+ AssertEqual '.x', g:map['xfiletype']
+ AssertEqual '.y', g:map['yfiletype']
+ AssertEqual '.z', g:map['zfiletype']
+ AssertEqual '.jsx', g:map['javascript.jsx']
+
+Execute(ALE should guess file extensions appropriately):
+ " The whole string should be used, if there's a match.
+ AssertEqual '.jsx', ale#filetypes#GuessExtension('javascript.jsx')
+ " The first part should be used.
+ AssertEqual '.x', ale#filetypes#GuessExtension('xfiletype.yfiletype')