diff options
Diffstat (limited to 'test/completion/test_completion_events.vader')
-rw-r--r-- | test/completion/test_completion_events.vader | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index 87bd10ad..30bf603c 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -50,8 +50,8 @@ Before: let g:handle_code_action_called = 0 function! MockHandleCodeAction() abort " delfunction! ale#code_action#HandleCodeAction - function! ale#code_action#HandleCodeAction(action, should_save) abort - AssertEqual v:false, a:should_save + function! ale#code_action#HandleCodeAction(action, options) abort + Assert !get(a:options, 'should_save') let g:handle_code_action_called += 1 endfunction endfunction @@ -407,41 +407,75 @@ Execute(HandleUserData should call ale#code_action#HandleCodeAction): AssertEqual g:handle_code_action_called, 0 call ale#completion#HandleUserData({ - \ 'user_data': '' + \ 'user_data': '' \}) AssertEqual g:handle_code_action_called, 0 call ale#completion#HandleUserData({ - \ 'user_data': '{}' + \ 'user_data': json_encode({}), \}) AssertEqual g:handle_code_action_called, 0 call ale#completion#HandleUserData({ - \ 'user_data': '{"codeActions": []}' + \ 'user_data': json_encode({ + \ '_ale_completion_item': 1, + \ 'code_actions': [], + \ }), \}) AssertEqual g:handle_code_action_called, 0 call ale#completion#HandleUserData({ - \ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}' + \ 'user_data': json_encode({ + \ '_ale_completion_item': 1, + \ 'code_actions': [ + \ {'description': '', 'changes': []}, + \ ], + \ }), \}) AssertEqual g:handle_code_action_called, 1 let b:ale_completion_info = {'source': 'ale-automatic'} call ale#completion#HandleUserData({ - \ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}' + \ 'user_data': json_encode({ + \ '_ale_completion_item': 1, + \ 'code_actions': [ + \ {'description': '', 'changes': []}, + \ ], + \ }), \}) AssertEqual g:handle_code_action_called, 2 let b:ale_completion_info = {'source': 'ale-callback'} call ale#completion#HandleUserData({ - \ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}' + \ 'user_data': json_encode({ + \ '_ale_completion_item': 1, + \ 'code_actions': [ + \ {'description': '', 'changes': []}, + \ ], + \ }), \}) AssertEqual g:handle_code_action_called, 3 + let b:ale_completion_info = {'source': 'ale-omnifunc'} + call ale#completion#HandleUserData({ + \ 'user_data': json_encode({ + \ '_ale_completion_item': 1, + \ 'code_actions': [ + \ {'description': '', 'changes': []}, + \ ], + \ }), + \}) + AssertEqual g:handle_code_action_called, 4 + Execute(ale#code_action#HandleCodeAction should not be called when when source is not ALE): call MockHandleCodeAction() let b:ale_completion_info = {'source': 'syntastic'} call ale#completion#HandleUserData({ - \ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}' + \ 'user_data': json_encode({ + \ '_ale_completion_item': 1, + \ 'code_actions': [ + \ {'description': '', 'changes': []}, + \ ], + \ }), \}) AssertEqual g:handle_code_action_called, 0 |