robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.1 KiB45 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 clear = n.clear
6local exec_lua = n.exec_lua
7local eq = t.eq
8local pcall_err = t.pcall_err
9
10describe('vim.spell', function()
11  before_each(function()
12    clear()
13  end)
14
15  describe('.check', function()
16    local check = function(x, exp)
17      return eq(exp, exec_lua('return vim.spell.check(...)', x))
18    end
19
20    it('can handle nil', function()
21      eq(
22        [[bad argument #1 to 'check' (expected string)]],
23        pcall_err(exec_lua, [[vim.spell.check(nil)]])
24      )
25    end)
26
27    it('can check spellings', function()
28      check('hello', {})
29
30      check('helloi', { { 'helloi', 'bad', 1 } })
31
32      check('hello therei', { { 'therei', 'bad', 7 } })
33
34      check('hello. there', { { 'there', 'caps', 8 } })
35
36      check('neovim cna chkc spellins. okay?', {
37        { 'neovim', 'bad', 1 },
38        { 'cna', 'bad', 8 },
39        { 'chkc', 'bad', 12 },
40        { 'spellins', 'bad', 17 },
41        { 'okay', 'caps', 27 },
42      })
43    end)
44  end)
45end)