Repository navigation
Expand file tree
/
Copy pathindex.test.js
More file actions
61 lines (47 loc) · 1.78 KB
/
Copy pathindex.test.js
File metadata and controls
61 lines (47 loc) · 1.78 KB
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
import { describe, expect, it } from "vitest";
import { analyzeDiceRolls, getCounts, getPoints } from "/index.js";
describe("Analyze dices to get points", () => {
it("YAMS + chance", () => {
expect(analyzeDiceRolls([[6, 6, 5, 5, 4], [5, 5, 5, 5, 5]])).toBe(76)
})
it("Full + YAMS", () => {
expect(analyzeDiceRolls([[6, 6, 6, 5, 5], [5, 5, 5, 5, 5]])).toBe(80)
})
it("Brelan + Carré + Grande suite", () => {
expect(analyzeDiceRolls([[1,1,1,5,6], [5,5,5,5,1], [3,4,1,2,5]])).toBe(103)
})
it("too many dices", () => {
expect(() => analyzeDiceRolls([[1, 2, 3, 4, 5, 6],[1, 2, 3, 4, 5]])).toThrow()
})
it("not enough dices", () => {
expect(() => analyzeDiceRolls([[1, 2, 3, 4],[1, 2, 3, 4, 5]])).toThrow()
})
it("one of dice number is not between 1-6", () => {
expect(() => analyzeDiceRolls([[1, 2, 3, 4, 8],[1, 2, 3, 4, 5]])).toThrow()
})
})
describe("Count how many time a die appear in a roll", () => {
it("count occurence of a die", () => {
expect(getCounts([6,6,1,2,2])).toEqual({6:2, 1:1, 2:2})
})
})
describe("return how many points you get from a roll", () => {
it("3 times the same die (Brelan)", () => {
expect(getPoints([2,2,2,4,5])).toBe(28)
})
it("4 times the same die (Carré)", () => {
expect(getPoints([2,2,2,2,5])).toBe(35)
})
it("5 times the same die (YAMS)", () => {
expect(getPoints([2,2,2,2,2])).toBe(50)
})
it("3 times the same die + 2 times the same die(Full)", () => {
expect(getPoints([2,2,2,3,3])).toBe(30)
})
it("5 die in a row(Grande suite)", () => {
expect(getPoints([3,4,5,1,2])).toBe(40)
})
it("No figures (Chance)", () => {
expect(getPoints([6,6,5,5,4])).toBe(26)
})
})