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