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
Screw.Unit(function() { | |
describe("bowling game scorecard", function() { | |
var bowlingGame; | |
before(function() { | |
bowlingGame = new BowlingGame(); | |
}); | |
function gutterBall() { | |
bowlingGame.roll(0); | |
} | |
function strike() { | |
bowlingGame.roll(10); | |
} | |
describe("normal games", function() { | |
it("should score a single throw", function() { | |
bowlingGame.roll(5); | |
(19).times(function() { gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 5); | |
}); | |
it("should score two throws which do not add up to a strike or spare", function() { | |
bowlingGame.roll(5); | |
bowlingGame.roll(4); | |
(18).times(function() { gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 9); | |
}); | |
it("should score a spare", function() { | |
(3).times(function() { bowlingGame.roll(5); }); | |
(17).times(function() { gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 20); | |
}); | |
it("should score multiple spares", function() { | |
(2).times(function() { bowlingGame.roll(5); }); | |
(2).times(function() { bowlingGame.roll(5); }); | |
bowlingGame.roll(5); | |
(15).times(function(){ gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 35); | |
}); | |
it("should score a strike", function() { | |
bowlingGame.roll(10); | |
bowlingGame.roll(5); | |
bowlingGame.roll(5); | |
(16).times(function() { gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 30); | |
}); | |
it("should score back to back strikes", function() { | |
(2).times(function() { strike(); }); | |
bowlingGame.roll(5); | |
bowlingGame.roll(4); | |
(14).times(function() { gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 53); | |
}); | |
it("should score a combination of strikes and spares", function() { | |
(3).times(function() { strike(); }); | |
(2).times(function() { bowlingGame.roll(5) }); | |
bowlingGame.roll(7); | |
(15).times(function() { gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 99); | |
}); | |
}); | |
describe("special games", function() { | |
it("should score a full house of strikes", function() { | |
(12).times(function() { strike(); }); | |
expect(bowlingGame.score()).to(equal, 300); | |
}); | |
it("should score a full house of spares", function() { | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
gutterBall(); | |
bowlingGame.roll(10); | |
bowlingGame.roll(10); | |
expect(bowlingGame.score()).to(equal, 110) | |
}); | |
it("should score a gutter game", function() { | |
(10).times(function() { gutterBall(); }); | |
expect(bowlingGame.score()).to(equal, 0); | |
}); | |
it("should score a dutch 200", function() { | |
strike(); | |
(2).times(function() { bowlingGame.roll(5) }); | |
strike(); | |
(2).times(function() { bowlingGame.roll(5) }); | |
strike(); | |
(2).times(function() { bowlingGame.roll(5) }); | |
strike(); | |
(2).times(function() { bowlingGame.roll(5) }); | |
strike(); | |
(2).times(function() { bowlingGame.roll(5) }); | |
strike(); | |
expect(bowlingGame.score()).to(equal, 200); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment