Skip to content

Commit

Permalink
test(settings): Test callbacks in push/pop scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Feb 3, 2024
1 parent 2e28023 commit 8cc06a6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/settings_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,26 @@ describe("The settings handler", function()
assert.is.equal("baz hooked", private)
end)

it("should trigger callbacks on push/pop events", function()
local mystate = "foo"
local function callback2 (value)
mystate = value .. " stack"
end
SILE.settings:declare({
parameter = "test.callback2",
type = "string",
default = "bar",
hook = callback2
})
SILE.settings:pushState()
SILE.settings:set("test.callback2", "baz1")
SILE.settings:pushState()
SILE.settings:set("test.callback2", "baz2")
assert.is.equal("baz2 stack", mystate)
SILE.settings:popState()
assert.is.equal("baz1 stack", mystate)
SILE.settings:popState()
assert.is.equal("bar stack", mystate)
end)

end)

0 comments on commit 8cc06a6

Please sign in to comment.