-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhigh-scores.spec.js
43 lines (35 loc) · 1.32 KB
/
high-scores.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { HighScores } from './high-scores';
describe('High Scores Test Suite', () => {
test('List of scores', () => {
const input = [30, 50, 20, 70];
expect(new HighScores(input).scores).toEqual([30, 50, 20, 70]);
});
test('Latest score', () => {
const input = [100, 0, 90, 30];
expect(new HighScores(input).latest).toEqual(30);
});
test('Personal best', () => {
const input = [40, 100, 70];
expect(new HighScores(input).personalBest).toEqual(100);
});
test('Personal top three from a list of scores', () => {
const input = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70];
expect(new HighScores(input).personalTopThree).toEqual([100, 90, 70]);
});
test('Personal top highest to lowest', () => {
const input = [20, 10, 30];
expect(new HighScores(input).personalTopThree).toEqual([30, 20, 10]);
});
test('Personal top when ther eis a tie', () => {
const input = [40, 20, 40, 30];
expect(new HighScores(input).personalTopThree).toEqual([40, 40, 30]);
});
test('Personal top when there are less than 3', () => {
const input = [30, 70];
expect(new HighScores(input).personalTopThree).toEqual([70, 30]);
});
test('Personal top when there is only one', () => {
const input = [40];
expect(new HighScores(input).personalTopThree).toEqual([40]);
});
});