diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/command_callback/test_tslint_command_callback.vader | 24 | ||||
-rw-r--r-- | test/handler/test_tslint_handler.vader | 32 | ||||
-rw-r--r-- | test/test_get_abspath.vader | 15 | ||||
-rw-r--r-- | test/test_loclist_corrections.vader | 2 |
4 files changed, 61 insertions, 12 deletions
diff --git a/test/command_callback/test_tslint_command_callback.vader b/test/command_callback/test_tslint_command_callback.vader new file mode 100644 index 00000000..694d36d6 --- /dev/null +++ b/test/command_callback/test_tslint_command_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:typescript_tslint_executable + Save g:typescript_tslint_config_path + Save g:typescript_tslint_use_global + + unlet! g:typescript_tslint_executable + unlet! g:typescript_tslint_config_path + unlet! g:typescript_tslint_use_global + + runtime ale_linters/typescript/tslint.vim + + call ale#test#SetDirectory('/testplugin/test/command_callback') + +After: + Restore + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(The default tslint command should be correct): + AssertEqual + \ 'cd ''' . expand('%:p:h') . ''' && ' + \ . 'tslint --format json %t', + \ ale_linters#typescript#tslint#GetCommand(bufnr('')) diff --git a/test/handler/test_tslint_handler.vader b/test/handler/test_tslint_handler.vader index a27657eb..5c8679a4 100644 --- a/test/handler/test_tslint_handler.vader +++ b/test/handler/test_tslint_handler.vader @@ -15,28 +15,40 @@ Execute(The tslint handler should parse lines correctly): \ { \ 'lnum': 1, \ 'col': 15, + \ 'filename': expand('%:p:h') . '/test.ts', \ 'end_lnum': 1, - \ 'end_col': 15, - \ 'text': 'semicolon: Missing semicolon', \ 'type': 'E', + \ 'end_col': 15, + \ 'text': 'semicolon: Missing semicolon' \ }, \ { \ 'lnum': 2, \ 'col': 8, + \ 'filename': expand('%:p:h') . '/test.ts', \ 'end_lnum': 3, + \ 'type': 'W', \ 'end_col': 12, - \ 'text': 'Something else', + \ 'text': 'Something else' + \ }, + \ { + \ 'lnum': 2, + \ 'col': 8, + \ 'filename': expand('%:p:h') . '/something-else.ts', + \ 'end_lnum': 3, \ 'type': 'W', + \ 'end_col': 12, + \ 'text': 'something: Something else' \ }, \ { \ 'lnum': 31, \ 'col': 9, + \ 'filename': expand('%:p:h') . '/test.ts', \ 'end_lnum': 31, - \ 'end_col': 20, - \ 'text': 'no-console: Calls to console.log are not allowed.', \ 'type': 'E', + \ 'end_col': 20, + \ 'text': 'no-console: Calls to console.log are not allowed.' \ }, - \ ], + \ ] , \ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([ \ { \ 'endPosition': { @@ -50,7 +62,7 @@ Execute(The tslint handler should parse lines correctly): \ 'innerStart': 14, \ 'innerText': ';' \ }, - \ 'name': 'app/test.ts', + \ 'name': 'test.ts', \ 'ruleName': 'semicolon', \ 'ruleSeverity': 'ERROR', \ 'startPosition': { @@ -71,7 +83,7 @@ Execute(The tslint handler should parse lines correctly): \ 'innerStart': 14, \ 'innerText': ';' \ }, - \ 'name': 'app/test.ts', + \ 'name': 'test.ts', \ 'ruleSeverity': 'WARNING', \ 'startPosition': { \ 'character': 7, @@ -91,7 +103,7 @@ Execute(The tslint handler should parse lines correctly): \ 'innerStart': 14, \ 'innerText': ';' \ }, - \ 'name': 'app/something-else.ts', + \ 'name': 'something-else.ts', \ 'ruleName': 'something', \ 'ruleSeverity': 'WARNING', \ 'startPosition': { @@ -107,7 +119,7 @@ Execute(The tslint handler should parse lines correctly): \ "position": 14590 \ }, \ "failure": "Calls to console.log are not allowed.", - \ 'name': 'app/test.ts', + \ 'name': 'test.ts', \ "ruleName": "no-console", \ "startPosition": { \ "character": 8, diff --git a/test/test_get_abspath.vader b/test/test_get_abspath.vader new file mode 100644 index 00000000..2def3773 --- /dev/null +++ b/test/test_get_abspath.vader @@ -0,0 +1,15 @@ +Execute(Relative paths should be resolved correctly): + AssertEqual + \ '/foo/bar/baz/whatever.txt', + \ ale#path#GetAbsPath('/foo/bar/xyz', '../baz/whatever.txt') + AssertEqual + \ '/foo/bar/xyz/whatever.txt', + \ ale#path#GetAbsPath('/foo/bar/xyz', './whatever.txt') + AssertEqual + \ '/foo/bar/xyz/whatever.txt', + \ ale#path#GetAbsPath('/foo/bar/xyz', 'whatever.txt') + +Execute(Absolute paths should be resolved correctly): + AssertEqual + \ '/ding/dong', + \ ale#path#GetAbsPath('/foo/bar/xyz', '/ding/dong') diff --git a/test/test_loclist_corrections.vader b/test/test_loclist_corrections.vader index e0a21da1..e6844d8e 100644 --- a/test/test_loclist_corrections.vader +++ b/test/test_loclist_corrections.vader @@ -303,7 +303,6 @@ Execute(FixLocList should interpret temporary filenames as being the current buf \ 'lnum': 2, \ 'col': 0, \ 'bufnr': bufnr(''), - \ 'filename': b:temp_name, \ 'vcol': 0, \ 'type': 'E', \ 'nr': -1, @@ -314,7 +313,6 @@ Execute(FixLocList should interpret temporary filenames as being the current buf \ 'lnum': 3, \ 'col': 0, \ 'bufnr': bufnr(''), - \ 'filename': b:temp_name, \ 'vcol': 0, \ 'type': 'E', \ 'nr': -1, |