forked from makersacademy/bowling-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe.test.js
63 lines (53 loc) · 1.54 KB
/
frame.test.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const Frame = require("./frame");
describe("Frame", () => {
beforeEach(() => {
frame = new Frame();
});
describe("Rolls", () => {
it("should start with no rolls", () => {
expect(frame.rolls()).toEqual(0);
});
it("should know how many rolls have been rolled", () => {
frame.addRoll(2);
expect(frame.rolls()).toEqual(1);
});
});
describe("Strike", () => {
it("should know if the frame is not a strike", () => {
frame.addRoll(2);
frame.addRoll(8);
expect(frame.isStrike()).toEqual(false);
});
it("should know if the frame is a strike", () => {
frame.addRoll(10);
expect(frame.isStrike()).toEqual(true);
});
});
describe("Spare", () => {
it("should know if the frame is not a spare", () => {
frame.addRoll(2);
frame.addRoll(2);
expect(frame.isSpare()).toEqual(false);
});
it("should know if the frame is a spare", () => {
frame.addRoll(2);
frame.addRoll(8);
expect(frame.isSpare()).toEqual(true);
});
});
it("should know how many pins were taken down in the first roll", () => {
frame.addRoll(2);
expect(frame.firstRoll()).toEqual(2);
});
it("should know how many pins were taken down in the second roll", () => {
frame.addRoll(2);
frame.addRoll(3);
expect(frame.secondRoll()).toEqual(3);
});
it("should know how many pins were taken down in the bonus roll", () => {
frame.addRoll(2);
frame.addRoll(8);
frame.addRoll(3);
expect(frame.bonusRoll()).toEqual(3);
});
});