summaryrefslogtreecommitdiff
path: root/test/fix/test_ale_fix_suggest.vader
blob: 1100aeed2f054372fae20c6f3e47a2a37b73b49f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Before:
  call ale#fix#registry#Clear()

  let g:buffer = bufnr('')

  function GetSuggestions()
    silent ALEFixSuggest

    if bufnr('') != g:buffer
      let l:lines = getline(1, '$')
    else
      let l:lines = []
    endif

    return l:lines
  endfunction

After:
  if bufnr('') != g:buffer
    :q!
  endif

  unlet! g:buffer

  call ale#fix#registry#ResetToDefaults()
  delfunction GetSuggestions

Execute(ALEFixSuggest should return something sensible with no suggestions):
  AssertEqual
  \ [
  \   'There is nothing in the registry to suggest.',
  \   '',
  \   'Press q to close this window',
  \ ],
  \ GetSuggestions()

Execute(ALEFixSuggest should set the appropriate settings):
  silent ALEFixSuggest

  AssertEqual 'ale-fix-suggest', &filetype
  Assert !&modified, 'The buffer was marked as modified'
  Assert !&modifiable, 'The buffer was modifiable'

Execute(ALEFixSuggest output should be correct for only generic handlers):
  call ale#fix#registry#Add('zed', 'XYZ', [], 'Zedify things.')
  call ale#fix#registry#Add('alpha', 'XYZ', [], 'Alpha things.')

  AssertEqual
  \ [
  \   'Try the following generic fixers:',
  \   '',
  \   '''alpha'' - Alpha things.',
  \   '''zed'' - Zedify things.',
  \   '',
  \   'See :help ale-fix-configuration',
  \   '',
  \   'Press q to close this window',
  \ ],
  \ GetSuggestions()

Execute(ALEFixSuggest output should be correct for only filetype handlers):
  let &filetype = 'testft2.testft'

  call ale#fix#registry#Add('zed', 'XYZ', ['testft2'], 'Zedify things.')
  call ale#fix#registry#Add('alpha', 'XYZ', ['testft'], 'Alpha things.')

  AssertEqual
  \ [
  \   'Try the following fixers appropriate for the filetype:',
  \   '',
  \   '''alpha'' - Alpha things.',
  \   '''zed'' - Zedify things.',
  \   '',
  \   'See :help ale-fix-configuration',
  \   '',
  \   'Press q to close this window',
  \ ],
  \ GetSuggestions()

Execute(ALEFixSuggest should suggest filetype and generic handlers):
  let &filetype = 'testft2.testft'

  call ale#fix#registry#Add('zed', 'XYZ', ['testft2'], 'Zedify things.', ['foobar'])
  call ale#fix#registry#Add('alpha', 'XYZ', ['testft'], 'Alpha things.')
  call ale#fix#registry#Add('generic', 'XYZ', [], 'Generic things.')

  AssertEqual
  \ [
  \   'Try the following fixers appropriate for the filetype:',
  \   '',
  \   '''alpha'' - Alpha things.',
  \   '''zed'', ''foobar'' - Zedify things.',
  \   '',
  \   'Try the following generic fixers:',
  \   '',
  \   '''generic'' - Generic things.',
  \   '',
  \   'See :help ale-fix-configuration',
  \   '',
  \   'Press q to close this window',
  \ ],
  \ GetSuggestions()