-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcard.test.ts
65 lines (55 loc) · 1.83 KB
/
card.test.ts
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
64
65
import { assert } from "chai";
import { GetCircle, GetStar, GetSquare, GetWhot } from "../src/card";
import Shapes from "../src/shapes";
describe("Card", () => {
it("should have a score", () => {
const circle = GetCircle({
value: 1,
});
assert.equal(circle.score, 1);
});
describe("Star", () => {
it("should have a double score", () => {
const star = GetStar({
value: 1,
});
assert.equal(star.score, 2);
});
});
describe(".matches()", () => {
it("should be false if cards have different shapes", () => {
assert.isFalse(GetSquare({ value: 1 }).matches(GetCircle({ value: 8 })));
});
it("should be true if cards have different shapes but same value", () => {
assert.isTrue(GetSquare({ value: 1 }).matches(GetCircle({ value: 1 })));
});
it("should be true if cards have same shape but different values", () => {
assert.isTrue(GetCircle({ value: 1 }).matches(GetCircle({ value: 8 })));
});
it("should be true if cards have same shape and same values", () => {
assert.isTrue(GetCircle({ value: 1 }).matches(GetCircle({ value: 1 })));
});
it("should be true if either card is whot", () => {
assert.isTrue(
GetCircle({ value: 1 }).matches(
GetWhot({ iNeed: Shapes.Circle, value: 20 })
)
);
assert.isTrue(
GetWhot({ iNeed: Shapes.Square, value: 20 }).matches(
GetSquare({ value: 2 })
)
);
});
it("should NOT match because whot card has no value", () => {
assert.isFalse(GetWhot({ value: 20 }).matches(GetSquare({ value: 13 })));
});
it("should match because whot card needs a Square", () => {
assert.isTrue(
GetWhot({ iNeed: Shapes.Square, value: 20 }).matches(
GetSquare({ value: 13 })
)
);
});
});
});