-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdeck.test.ts
52 lines (44 loc) · 1.3 KB
/
deck.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
import { assert } from "chai";
import Deck from "../src/deck";
import Card from "../src/card";
import { EventEmitter } from "../src/events";
const MAX_NO_OF_CARDS = 54;
describe("Deck", () => {
const deck = new Deck({
emitter: new EventEmitter()
});
it("should have cards array", () => {
assert.isArray(deck.cards);
});
describe("Deck.prototype.cards", () => {
describe("length", () => {
it(`should be ${MAX_NO_OF_CARDS}`, () => {
assert.equal(deck.cards.length, MAX_NO_OF_CARDS);
});
});
describe("shuffle", () => {
describe("length", () => {
it(`should be ${MAX_NO_OF_CARDS}`, () => {
assert.equal(deck.shuffle().length, MAX_NO_OF_CARDS);
});
});
it("should have every card", () => {
deck.shuffle().forEach((shuffleCard) => {
const card = deck.cards.find((card) => {
return (
card.shape === shuffleCard.shape &&
card.value === shuffleCard.value
);
});
assert.isDefined(card);
});
});
});
it("should have .shuffle()", () => {
assert.typeOf(deck.shuffle, "function");
});
it("should have instances of Card", () => {
deck.cards.forEach((card) => assert.instanceOf(card, Card));
});
});
});