Created
December 24, 2012 13:39
-
-
Save vgheri/4369283 to your computer and use it in GitHub Desktop.
qUnit unit test example
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
//process_input(player) : number // returns the increment on the y axis | |
test("Test process_input", function () { | |
// Test 1 | |
var commands1 = ["up", "up"]; | |
var inputs = [{ commands: commands1, sequenceNumber: 0}]; | |
var player = { inputs: inputs, lastProcessedInputId: -1 }; | |
var expectedIncrement = -20; | |
var observedIncrement = PongR.UnitTestPrototype.process_input(player, 10, 1); | |
deepEqual(observedIncrement, expectedIncrement); | |
deepEqual(player.lastProcessedInputId, 0); | |
// Test 2 | |
commands1 = ["up", "down"]; | |
inputs = [{ commands: commands1, sequenceNumber: 1}]; | |
player = { inputs: inputs, lastProcessedInputId: 0 }; | |
expectedIncrement = 0; | |
observedIncrement = PongR.UnitTestPrototype.process_input(player, 10, 1); | |
deepEqual(observedIncrement, expectedIncrement); | |
deepEqual(player.lastProcessedInputId, 1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment