Skip to content

Commit 78ef395

Browse files
Fix unit test & use mock for latex testing
1 parent 01ad32f commit 78ef395

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

tests/box_dash_quote_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async_tests.describe('box_dash_quote.md', function()
5454
{
5555
row = { 5 },
5656
col = { 0 },
57-
virt_text = { { string.rep('', vim.opt.columns:get()), 'LineNr' } },
57+
virt_text = { { string.rep('', vim.opt.columns:get()), 'LineNr' } },
5858
virt_text_pos = 'overlay',
5959
},
6060
})

tests/latex_spec.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
local async_tests = require('plenary.async.tests')
2+
local stub = require('luassert.stub')
23
local util = require('tests.util')
34

5+
local eq = assert.are.same
6+
47
async_tests.describe('latex.md', function()
58
async_tests.it('default', function()
6-
-- TODO: mock interaction with latex2text
9+
stub.new(vim.fn, 'executable', function(expr)
10+
eq('latex2text', expr)
11+
return 1
12+
end)
13+
stub.new(vim.fn, 'system', function(cmd, input)
14+
eq('latex2text', cmd)
15+
local responses = {
16+
['$\\sqrt{3x-1}+(1+x)^2$'] = '√(3x-1)+(1+x)^2\n',
17+
['$$\nf(x,y) = x + \\sqrt{y}\nf(x,y) = \\sqrt{y} + \\frac{x^2}{4y}\n$$'] = '\n f(x,y) = x + √(y)\n f(x,y) = √(y) + x^2/4y\n\n',
18+
}
19+
return responses[input]
20+
end)
21+
722
util.setup('demo/latex.md')
823

924
local expected = {}

0 commit comments

Comments
 (0)