forked from makersacademy/bowling-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big refactor of unit tests; Added feature and integration tests; Fini…
…shed bonus logic;
- Loading branch information
Showing
11 changed files
with
416 additions
and
116 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
describe('Play', function () { | ||
it('updates the scorecard with correct frame scores after normal frame', function () { | ||
var game, scorecard; | ||
game = new Game(); | ||
spyOn(Math, 'random').and.returnValues(0.2, 0.6, 0.1); | ||
game.play(); | ||
game.play(); | ||
game.play(); | ||
scorecard = game.getScoreCard(); | ||
expect(scorecard.getCard()).toEqual([[2, 5], [1]]); | ||
}); | ||
it('updates the scorecard with correct frame scores after spare', function () { | ||
var game, scorecard; | ||
game = new Game(); | ||
spyOn(Math, 'random').and.returnValues(0.51, 0.9, 0.1); | ||
game.play(); | ||
game.play(); | ||
game.play(); | ||
scorecard = game.getScoreCard(); | ||
expect(scorecard.getCard()).toEqual([[5, 5, 1], [1]]); | ||
}); | ||
it('play a gutter game', function () { | ||
var game, scorecard; | ||
game = new Game(); | ||
spyOn(Math, 'random').and.returnValue(0); | ||
for (var i = 0; i < 20; i++) { | ||
game.play(); | ||
} | ||
scorecard = game.getScoreCard(); | ||
expect(scorecard.getCard().length).toEqual(10); | ||
expect(game.getTotalScore()).toEqual(0); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict'; | ||
|
||
describe('ScoreCardIntegration', function () { | ||
var card; | ||
|
||
beforeEach(function () { | ||
card = new ScoreCard(); | ||
}); | ||
|
||
describe('updateCard', function () { | ||
beforeEach(function () { | ||
card.card = [[]]; | ||
}); | ||
it('logs two new frames on card', function () { | ||
card.updateCard(1); | ||
card.updateCard(2); | ||
card.updateCard(3); | ||
expect(card.getCard()).toEqual([[1, 2], [3]]); | ||
}); | ||
it('logs three new frames on card', function () { | ||
card.updateCard(1); | ||
card.updateCard(2); | ||
card.updateCard(3); | ||
card.updateCard(4); | ||
card.updateCard(5); | ||
expect(card.getCard()).toEqual([[1, 2], [3, 4], [5]]); | ||
}); | ||
it('adds bonus to previous frame array on spare', function () { | ||
card.updateCard(1); | ||
card.updateCard(9); | ||
card.updateCard(3); | ||
expect(card.getCard()).toEqual([[1, 9, 3], [3]]); | ||
}); | ||
it('does not add second roll as bonus to previous frame on spare', function () { | ||
card.updateCard(1); | ||
card.updateCard(9); | ||
card.updateCard(3); | ||
card.updateCard(5); | ||
expect(card.getCard()).toEqual([[1, 9, 3], [3, 5]]); | ||
}); | ||
it('adds both bonus rolls to previous frame array on strike', function () { | ||
card.updateCard(1); | ||
card.updateCard(3); | ||
card.updateCard(10); | ||
card.updateCard(0); | ||
card.updateCard(2); | ||
card.updateCard(4); | ||
expect(card.getCard()).toEqual([[1, 3], [10, 0, 2, 4], [2, 4]]); | ||
}); | ||
it('adds both bonus rolls to previous frame array on first frame strike', function () { | ||
card.updateCard(10); | ||
card.updateCard(0); | ||
card.updateCard(2); | ||
card.updateCard(4); | ||
expect(card.getCard()).toEqual([[10, 0, 2, 4], [2, 4]]); | ||
}); | ||
}); | ||
}); |
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
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
Oops, something went wrong.