1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-14 01:06:48 +00:00
CC-Tweaked/src/test/resources/test-rom/spec/programs/pocket/unequip_spec.lua
JakobDev e05c262468 Add more tests (#253)
I'm not entirely sure how useful all of these will be yet - still
trying to work out what/when to test things, but hopefully this'll
be a useful datapoint.
2019-07-08 09:24:05 +01:00

28 lines
986 B
Lua

local capture = require "test_helpers".capture_program
describe("The pocket unequip program", function()
it("errors when not a pocket computer", function()
stub(_G, "pocket", nil)
expect(capture(stub, "/rom/programs/pocket/unequip.lua"))
:matches { ok = true, output = "", error = "Requires a Pocket Computer\n" }
end)
it("unequips an upgrade", function()
stub(_G, "pocket", {
unequipBack = function() return true end
})
expect(capture(stub, "/rom/programs/pocket/unequip.lua"))
:matches { ok = true, output = "Item unequipped\n", error = "" }
end)
it("handles when an upgrade cannot be equipped", function()
stub(_G, "pocket", {
unequipBack = function() return false, "Nothing to remove." end
})
expect(capture(stub, "/rom/programs/pocket/unequip.lua"))
:matches { ok = true, output = "", error = "Nothing to remove.\n" }
end)
end)