Skip to content

Commit

Permalink
better?
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Jan 6, 2024
1 parent 597f7fd commit 365d15a
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions tests/hawtkeys/e2e_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---@diagnostic disable-next-line: undefined-field
local eq = assert.are.same
local truthy = assert.is_true
local ts = require("hawtkeys.ts")

local function copy_configs_to_stdpath_config()
Expand All @@ -19,30 +18,55 @@ describe("file searching", function()
end)

it("can detect a Vim Default Keymap", function()
local notMatch = 0
local keymaps = ts.get_all_keymaps()
print(vim.inspect(keymaps))
truthy(vim.tbl_contains(keymaps, function(v)
return vim.deep_equal(v, {
from_file = "Vim Defaults",
lhs = "Y",
mode = "n",
rhs = "y$",
})
end, { predicate = true }))
for _, v in ipairs(keymaps) do
if
vim.deep_equal(v, {
from_file = "Vim Defaults",
lhs = "Y",
mode = "n",
rhs = "y$",
})
then
eq(v, {
from_file = "Vim Defaults",
lhs = "Y",
mode = "n",
rhs = "y$",
})
else
notMatch = notMatch + 1
end
end
eq(vim.tbl_count(keymaps), notMatch + 1)
end)

it("can detect a keymap from a file", function()
local notMatch = 0
local keymaps = ts.get_all_keymaps()
print(vim.fn.stdpath("config"))
print(vim.inspect(keymaps))
truthy(vim.tbl_contains(keymaps, function(v)
return vim.deep_equal(v, {
from_file = vim.fn.stdpath("config") .. "/e2e_config.lua",
lhs = "<leader>example",
mode = "n",
rhs = "<cmd>echo 'Example'<cr>",
})
end, { predicate = true }))

for _, v in ipairs(keymaps) do
if
vim.deep_equal(v, {
from_file = vim.fn.stdpath("config") .. "/e2e_config.lua",
lhs = "<leader>example",
mode = "n",
rhs = "<cmd>echo 'Example'<cr>",
})
then
eq(v, {
from_file = vim.fn.stdpath("config") .. "/e2e_config.lua",
lhs = "<leader>example",
mode = "n",
rhs = "<cmd>echo 'Example'<cr>",
})
else
notMatch = notMatch + 1
end
end

eq(vim.tbl_count(keymaps), notMatch + 1)
end)

it("should find a file in stdpath('config')", function()
Expand Down

0 comments on commit 365d15a

Please sign in to comment.