summaryrefslogtreecommitdiff
path: root/test/fixers/test_prettier_eslint_fixer.callback.vader
blob: 90e116720bba792e660d1bba8448f3a4e2260003 (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
Before:
  call ale#assert#SetUpFixerTest('javascript', 'prettier_eslint')

After:
  call ale#assert#TearDownFixerTest()

Execute(The default command should be correct):
  AssertFixer
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape('prettier-eslint')
  \     . ' %t'
  \     . ' --write'
  \ }

Execute(Additional options should be used when set):
  let b:ale_javascript_prettier_eslint_options = '--foobar'

  AssertFixer
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape('prettier-eslint')
  \     . ' %t'
  \     . ' --foobar --write'
  \ }

Execute(--eslint-config-path should be set for 4.2.0 and up):
  call ale#test#SetFilename('eslint-test-files/react-app/foo/bar.js')

  GivenCommandOutput ['4.2.0']
  AssertFixer
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape('prettier-eslint')
  \     . ' %t'
  \     . ' --eslint-config-path ' . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/.eslintrc.js'))
  \     . ' --write'
  \ }

Execute(--eslint-config-path shouldn't be used for older versions):
  call ale#test#SetFilename('eslint-test-files/react-app/foo/bar.js')

  AssertFixer
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape('prettier-eslint')
  \     . ' %t'
  \     . ' --write'
  \ }

Execute(The version check should be correct):
  AssertFixer [
  \ ale#Escape('prettier-eslint') . ' --version',
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape('prettier-eslint')
  \     . ' %t'
  \     . ' --write'
  \ }
  \]

Execute(The new --stdin-filepath option should be used when the version is new enough):
  call ale#test#SetFilename('eslint-test-files/react-app/foo/bar.js')

  GivenCommandOutput ['4.4.0']
  AssertFixer
  \ {
  \   'command': ale#path#CdString(expand('%:p:h'))
  \     . ale#Escape('prettier-eslint')
  \     . ' --eslint-config-path ' . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/.eslintrc.js'))
  \     . ' --stdin-filepath %s --stdin',
  \ }

Execute(The version number should be cached):
  GivenCommandOutput ['4.4.0']
  AssertFixer
  \ {
  \   'command': ale#path#CdString(expand('%:p:h'))
  \     . ale#Escape('prettier-eslint')
  \     . ' --stdin-filepath %s --stdin',
  \ }

  GivenCommandOutput []
  AssertFixer
  \ {
  \   'command': ale#path#CdString(expand('%:p:h'))
  \     . ale#Escape('prettier-eslint')
  \     . ' --stdin-filepath %s --stdin',
  \ }