Last active
October 22, 2021 10:58
-
-
Save Cst2989/c6e328504d5b2ae513d8061acb43d8d8 to your computer and use it in GitHub Desktop.
Bowling score card test
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
describe('bowlingScoreCard function', () => { | |
test('it should correct scorecard when no strikes/spares', () => { | |
const frames = [ | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
]; | |
const scoreCard = bowlingScoreCard(frames); | |
expect(scoreCard).toBe('2222222222'); | |
}); | |
test('it should return correct scorecard when spare is present', () => { | |
const frames = [ | |
[7, 3], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[9, 1], | |
[1, 1], | |
]; | |
const scoreCard = bowlingScoreCard(frames); | |
expect(scoreCard).toBe('/2222222/2'); | |
}); | |
test('it should return correct scorecard when strike is present', () => { | |
const frames = [ | |
[7, 3], | |
[1, 1], | |
[10, 0], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[1, 1], | |
[9, 1], | |
[10, 0], | |
]; | |
const scoreCard = bowlingScoreCard(frames); | |
expect(scoreCard).toBe('/2X22222/X'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment