aboutsummaryrefslogtreecommitdiffstats
path: root/tests/indent/jsx_spec.lua
blob: e75b21f4f7831624c806cccef4069ff91758e5a3 (plain) (blame)
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
local Runner = require("tests.indent.common").Runner
local runner = Runner:new(it, "tests/indent/jsx", {
  tabstop = 2,
  shiftwidth = 2,
  expandtab = true,
  filetype = "jsx",
})

describe("indent JSX Elements:", function()
  describe("whole file:", function()
    runner:whole_file(".", {
      expected_failures = {},
    })
  end)

  describe("new line:", function()
    for _, info in ipairs {
      { 5, 8 },
      { 6, 6 },
      { 7, 6 },
      { 8, 4 },
      { 9, 2 },
    } do
      runner:new_line("issue-3986.jsx", { on_line = info[1], text = "text", indent = info[2] })
    end
    for _, info in ipairs {
      { 4, 8 },
      { 6, 10 },
      { 9, 8 },
      { 11, 8 },
    } do
      runner:new_line("element_attributes.jsx", { on_line = info[1], text = "disabled", indent = info[2] })
    end

    for _, info in ipairs {
      { 5, 10 },
      { 7, 8 },
      { 11, 10 },
    } do
      runner:new_line("jsx_expression.jsx", { on_line = info[1], text = "{disabled}", indent = info[2] })
    end
  end)
end)