neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

spell_spec.lua (1046B)


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