Skip to content

Commit

Permalink
Also test infoview mappings are properly set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Oct 15, 2024
1 parent 1b44c09 commit 273749f
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions spec/mappings_spec.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
local infoview = require 'lean.infoview'
local lean = require 'lean'
local clean_buffer = require('spec.helpers').clean_buffer

vim.g.lean_config = { mappings = true }

describe('mappings', function()
it(
'are bound in lean buffers and not others',
clean_buffer(function()
assert.is.same(lean.mappings.n['<LocalLeader>i'], vim.fn.maparg('<LocalLeader>i', 'n'))
describe('for lean buffers', function()
local any_lean_lhs = '<LocalLeader>i'
local rhs = lean.mappings.n[any_lean_lhs]

it(
'are bound in lean buffers',
clean_buffer(function()
assert.is.not_nil(rhs)
assert.is.same(rhs, vim.fn.maparg(any_lean_lhs, 'n'))
end)
)

it('are not bound in other buffers', function()
vim.cmd.new()
assert.is.empty(vim.fn.maparg(any_lean_lhs, 'n'))
vim.cmd.bwipeout()
end)
end)

describe('for infoviews', function()
local any_infoview_lhs = '<Esc>'

it(
'are bound in infoviews',
clean_buffer(function()
infoview.go_to()
local mapping = vim.fn.maparg(any_infoview_lhs, 'n', false, true)
assert.is.same('function', type(mapping.callback))
end)
)

it('are not bound in other buffers', function()
vim.cmd.new()
assert.is.empty(vim.fn.maparg('<LocalLeader>i', 'n'))
assert.is.empty(vim.fn.maparg(any_infoview_lhs, 'n', false, true))
vim.cmd.bwipeout()
end)
)
end)
end)

0 comments on commit 273749f

Please sign in to comment.