Skip to content

Instantly share code, notes, and snippets.

@Cst2989
Last active October 22, 2021 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cst2989/c6e328504d5b2ae513d8061acb43d8d8 to your computer and use it in GitHub Desktop.
Save Cst2989/c6e328504d5b2ae513d8061acb43d8d8 to your computer and use it in GitHub Desktop.
Bowling score card test
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