hephaestus/heph.nvim/tests/e2e/home_spec.lua

27 lines
853 B
Lua
Raw Normal View History

-- The home / index landing page: open-or-create by title, idempotent.
local h = require("e2e.helpers")
describe("home page", function()
local ctx
before_each(function()
ctx = h.start()
end)
after_each(function()
h.stop(ctx)
end)
it("creates the home page on first open and reuses it after", function()
local n1 = require("heph.home").open("Home")
assert.is_truthy(n1.id)
assert.are.equal("heph://node/" .. n1.id, vim.api.nvim_buf_get_name(0))
assert.are.equal("doc", n1.kind)
-- Reopening returns the SAME doc (open-or-create is idempotent by title).
local n2 = require("heph.home").open("Home")
assert.are.equal(n1.id, n2.id)
-- It's a real, resolvable wiki target, so other notes can [[Home]] into it.
assert.are.equal(n1.id, ctx.q:call("node.resolve", { title = "Home" }).id)
end)
end)