Created
July 16, 2022 17:51
-
-
Save deepal/d4fd6046aedb472362b9130aee559a27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("app module", function () | |
describe("run() function", function () | |
local check_env_stub = stub() | |
setup(function () | |
package.preload["lib.check_env"] = function () | |
return check_env_stub | |
end | |
end) | |
teardown(function () | |
package.preload["lib.check_env"] = nil | |
end) | |
after_each(function () | |
check_env_stub:revert() | |
end) | |
it("should return a string if all criteria are met", function () | |
local app = require("lib.app") | |
check_env_stub.returns(true) | |
assert.same("Result of 10 + 20 is 30", app.run()) | |
end) | |
it("should return nil if all criteria are not met", function () | |
local app = require("lib.app") | |
check_env_stub.returns(false) | |
assert.is_nil(app.run()) | |
end) | |
end) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment