1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-25 19:07:39 +00:00

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.
This commit is contained in:
JakobDev
2019-07-08 10:24:05 +02:00
committed by SquidDev
parent 7a3f7d3bba
commit e05c262468
32 changed files with 727 additions and 20 deletions

View File

@@ -1,19 +1,18 @@
local capture = require "test_helpers".capture_program
describe("The cd program", function()
it("cd into a directory", function()
shell.run("cd /rom/programs")
expect(shell.dir()):eq("rom/programs")
it("changes into a directory", function()
local setDir = stub(shell, "setDir")
capture(stub, "cd /rom/programs")
expect(setDir):called_with("rom/programs")
end)
it("cd into a not existing directory", function()
it("does not move into a non-existent directory", function()
expect(capture(stub, "cd /rom/nothing"))
:matches { ok = true, output = "Not a directory\n", error = "" }
end)
it("displays the usage with no arguments", function()
it("displays the usage when given no arguments", function()
expect(capture(stub, "cd"))
:matches { ok = true, output = "Usage: cd <path>\n", error = "" }
end)