Files
nvim-cmp/lua/cmp/utils/str_spec.lua
hituzi no sippo a58712bf16 fix StyLua command (#190)
* style: fix StyLua glob pattern

* style: fix style with StyLua

run './utils/stylua --config-path stylua.toml --glob 'lua/**/*.lua' -- lua'
2021-09-11 20:18:44 +09:00

30 lines
1.2 KiB
Lua

local str = require('cmp.utils.str')
describe('utils.str', function()
it('get_word', function()
assert.are.equal(str.get_word('print'), 'print')
assert.are.equal(str.get_word('$variable'), '$variable')
assert.are.equal(str.get_word('print()'), 'print')
assert.are.equal(str.get_word('["cmp#confirm"]'), '["cmp#confirm"]')
assert.are.equal(str.get_word('"devDependencies":', string.byte('"')), '"devDependencies')
end)
it('strikethrough', function()
assert.are.equal(str.strikethrough('あいうえお'), 'あ̶い̶う̶え̶お̶')
end)
it('remove_suffix', function()
assert.are.equal(str.remove_suffix('log()', '$0'), 'log()')
assert.are.equal(str.remove_suffix('log()$0', '$0'), 'log()')
assert.are.equal(str.remove_suffix('log()${0}', '${0}'), 'log()')
assert.are.equal(str.remove_suffix('log()${0:placeholder}', '${0}'), 'log()${0:placeholder}')
end)
it('escape', function()
assert.are.equal(str.escape('plain', {}), 'plain')
assert.are.equal(str.escape('plain\\', {}), 'plain\\\\')
assert.are.equal(str.escape('plain\\"', {}), 'plain\\\\"')
assert.are.equal(str.escape('pla"in', { '"' }), 'pla\\"in')
end)
end)