Skip to content

Commit

Permalink
tests for line_begin and line_end
Browse files Browse the repository at this point in the history
  • Loading branch information
atticus-sullivan committed Oct 1, 2022
1 parent c917e62 commit 70b1cfd
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/unit/expand_conditions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,55 @@ describe("expand_conditions", function()
end
end)
end)
describe("line_begin", function()
it("is at begin", function()
local function foo()
return helpers.exec_lua([[
local cond = require("luasnip.extras.expand_conditions")
local c = cond.line_begin
return not c("hello world", "hello world") ~= true -- allow nil/object
]])
end
assert.has_no.errors(foo)
assert.is_true(foo())
end)
it("is NOT at begin", function()
local function foo()
return helpers.exec_lua([[
local cond = require("luasnip.extras.expand_conditions")
local c = cond.line_begin
return not c("hello world", "ld") ~= false -- allow nil/object
]])
end
assert.has_no.errors(foo)
assert.is_true(foo())
end)
end)
describe("line_end", function()
it("is at begin", function()
local function foo()
return helpers.exec_lua([[
-- vim.api.nvim_get_current_line
vim = {api = {nvim_get_current_line = function() return "hello world ending" end}}
local cond = require("luasnip.extras.expand_conditions")
local c = cond.line_end
return not c("hello world ending") ~= true -- allow nil/object
]])
end
assert.has_no.errors(foo)
assert.is_true(foo())
end)
it("is NOT at begin", function()
local function foo()
return helpers.exec_lua([[
vim = {api = {nvim_get_current_line = function() return "hello world ending" end}}
local cond = require("luasnip.extras.expand_conditions")
local c = cond.line_end
return not c("hello world") ~= false -- allow nil/object
]])
end
assert.has_no.errors(foo)
assert.is_true(foo())
end)
end)
end)

0 comments on commit 70b1cfd

Please sign in to comment.