Skip to content

Commit

Permalink
test(pages): pages and pages_unordered
Browse files Browse the repository at this point in the history
Coverage % did not change dispite tests added.
  • Loading branch information
Lazerbeak12345 committed Oct 7, 2023
1 parent 8489600 commit 23a6c8e
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions spec/sway_inv_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ describe("pages", function ()
sway.pages_unordered = {}
end)
describe("register_page", function ()
it("is a function on sway", function ()
assert.equal("function", type(sway.register_page))
end)
it("requires name", function ()
assert.has_error(function ()
sway.register_page()
Expand Down Expand Up @@ -101,6 +104,9 @@ describe("pages", function ()
end)
end)
describe("override_page", function ()
it("is a function on sway", function ()
assert.equal("function", type(sway.override_page))
end)
it("requires name", function ()
assert.has_error(function ()
sway.override_page()
Expand Down Expand Up @@ -175,8 +181,37 @@ describe("pages", function ()
end, "[sway] override_page: When overriding get, it must be a function.")
end)
end)
pending"pages"
pending"pages_unordered"
describe("pages", function ()
it("is a table on sway", function ()
assert.equal("table", type(sway.pages))
end)
it("register_page adds to this table by pagename", function ()
local def = { get = function () end }
sway.register_page(testpagename, def)
local def2 = { get = function () end }
sway.register_page(testpagename .. "1", def2)
assert.same({
[testpagename]= def,
[testpagename .. "1"]= def2
}, sway.pages)
assert.equal(def, sway.pages[testpagename])
assert.equal(def2, sway.pages[testpagename .. "1"])
end)
end)
describe("pages_unordered", function ()
it("is a table on sway", function ()
assert.equal("table", type(sway.pages_unordered))
end)
it("register_page adds to this table by order registered", function ()
local def = { get = function () end }
sway.register_page(testpagename, def)
local def2 = { get = function () end }
sway.register_page(testpagename .. "1", def2)
assert.same({ def, def2 }, sway.pages_unordered)
assert.equal(def, sway.pages_unordered[1])
assert.equal(def2, sway.pages_unordered[2])
end)
end)
pending"get_homepage_name"
pending"set_page"
pending"get_page"
Expand Down

0 comments on commit 23a6c8e

Please sign in to comment.