mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +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:
		
							
								
								
									
										34
									
								
								src/test/resources/test-rom/spec/programs/label_spec.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/test/resources/test-rom/spec/programs/label_spec.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| local capture = require "test_helpers".capture_program | ||||
|  | ||||
| describe("The label program", function() | ||||
|     it("displays its usage when given no arguments", function() | ||||
|         expect(capture(stub, "label")) | ||||
|             :matches { ok = true, output = "Usages:\nlabel get\nlabel get <drive>\nlabel set <text>\nlabel set <drive> <text>\nlabel clear\nlabel clear <drive>\n", error = "" } | ||||
|     end) | ||||
|  | ||||
|     describe("displays the computer's label", function() | ||||
|         it("when it is not labelled", function() | ||||
|             stub(os, "getComputerLabel", function() return nil end) | ||||
|             expect(capture(stub, "label get")) | ||||
|                 :matches { ok = true, output = "No Computer label\n", error = "" } | ||||
|         end) | ||||
|  | ||||
|         it("when it is labelled", function() | ||||
|             stub(os, "getComputerLabel", function() return "Test" end) | ||||
|             expect(capture(stub, "label get")) | ||||
|                 :matches { ok = true, output = "Computer label is \"Test\"\n", error = "" } | ||||
|         end) | ||||
|     end) | ||||
|  | ||||
|     it("sets the computer's label", function() | ||||
|         local setComputerLabel = stub(os, "setComputerLabel") | ||||
|         capture(stub, "label set Test") | ||||
|         expect(setComputerLabel):called_with("Test") | ||||
|     end) | ||||
|  | ||||
|     it("clears the computer's label", function() | ||||
|         local setComputerLabel = stub(os, "setComputerLabel") | ||||
|         capture(stub, "label clear") | ||||
|         expect(setComputerLabel):called_with(nil) | ||||
|     end) | ||||
| end) | ||||
		Reference in New Issue
	
	Block a user
	 JakobDev
					JakobDev