summaryrefslogtreecommitdiff
path: root/test/fixers/test_elm_format_fixer_callback.vader
blob: 3524473706981e471ffa3c72202540d576728e8f (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
Before:
  call ale#test#SetDirectory('/testplugin/test/fixers')

After:
  unlet! b:ale_elm_format_executable
  unlet! b:ale_elm_format_use_global
  unlet! b:ale_elm_format_options

  call ale#test#RestoreDirectory()

Execute(The elm-format command should have default params):
  call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')

  AssertEqual
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape(ale#path#Simplify(g:dir . '/../test-files/elm/node_modules/.bin/elm-format'))
  \     . ' %t --yes',
  \ },
  \ ale#fixers#elm_format#Fix(bufnr(''))

Execute(The elm-format command should manage use_global = 1 param):
  call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
  let b:ale_elm_format_use_global = 1

  AssertEqual
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape('elm-format')
  \     . ' %t --yes',
  \ },
  \ ale#fixers#elm_format#Fix(bufnr(''))

Execute(The elm-format command should manage executable param):
  call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
  let b:ale_elm_format_use_global = 1
  let b:ale_elm_format_executable = 'elmformat'

  AssertEqual
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape('elmformat')
  \     . ' %t --yes',
  \ },
  \ ale#fixers#elm_format#Fix(bufnr(''))

Execute(The elm-format command should manage empty options):
  call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
  let b:ale_elm_format_options = ''

  AssertEqual
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape(ale#path#Simplify(g:dir . '/../test-files/elm/node_modules/.bin/elm-format'))
  \     . ' %t',
  \ },
  \ ale#fixers#elm_format#Fix(bufnr(''))

Execute(The elm-format command should manage custom options):
  call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
  let b:ale_elm_format_options = '--param1 --param2'

  AssertEqual
  \ {
  \   'read_temporary_file': 1,
  \   'command':
  \     ale#Escape(ale#path#Simplify(g:dir . '/../test-files/elm/node_modules/.bin/elm-format'))
  \     . ' %t --param1 --param2',
  \ },
  \ ale#fixers#elm_format#Fix(bufnr(''))