robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.3 KiB63 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3
4local describe, it, before_each = t.describe, t.it, t.before_each
5local exec_lua = n.exec_lua
6local eq = t.eq
7
8local function md_to_vimdoc(text, start_indent, indent, text_width)
9  return exec_lua(
10    [[
11    local text, start_indent, indent, text_width = ...
12    start_indent = start_indent or 0
13    indent = indent or 0
14    text_width = text_width or 70
15    local util = require('src/gen/util')
16    return util.md_to_vimdoc(table.concat(text, '\n'), start_indent, indent, text_width)
17  ]],
18    text,
19    start_indent,
20    indent,
21    text_width
22  )
23end
24
25local function test(what, act, exp, ...)
26  local argc, args = select('#', ...), { ... }
27  it(what, function()
28    eq(table.concat(exp, '\n'), md_to_vimdoc(act, unpack(args, 1, argc)))
29  end)
30end
31
32describe('md_to_vimdoc', function()
33  before_each(function()
34    n.clear()
35  end)
36
37  test('can render para after fenced code', {
38    '- Para1',
39    '  ```',
40    '  code',
41    '  ```',
42    '  Para2',
43  }, {
44    '• Para1 >',
45    '    code',
46    '<',
47    '  Para2',
48    '',
49  })
50
51  test('start_indent only applies to first line', {
52    'para1',
53    '',
54    'para2',
55  }, {
56    'para1',
57    '',
58    '          para2',
59    '',
60  }, 0, 10, 78)
61
62  test('inline 1', { '(`string`)' }, { '(`string`)', '' })
63end)