spell_spec.lua 1.1 KB

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