-
Notifications
You must be signed in to change notification settings - Fork 0
/
cell-to-box.spec.js
127 lines (118 loc) · 3.8 KB
/
cell-to-box.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const cellToBox = require('./cell-to-box');
describe('cells of first box', () => {
it('should return the first box', () => {
expect(cellToBox(0, 0)).toBe(0);
expect(cellToBox(0, 1)).toBe(0);
expect(cellToBox(0, 2)).toBe(0);
expect(cellToBox(1, 0)).toBe(0);
expect(cellToBox(1, 1)).toBe(0);
expect(cellToBox(1, 2)).toBe(0);
expect(cellToBox(2, 0)).toBe(0);
expect(cellToBox(2, 1)).toBe(0);
expect(cellToBox(2, 2)).toBe(0);
});
});
describe('cells of second box', () => {
it('should return the second box', () => {
expect(cellToBox(0, 3)).toBe(1);
expect(cellToBox(0, 4)).toBe(1);
expect(cellToBox(0, 5)).toBe(1);
expect(cellToBox(1, 3)).toBe(1);
expect(cellToBox(1, 4)).toBe(1);
expect(cellToBox(1, 5)).toBe(1);
expect(cellToBox(2, 3)).toBe(1);
expect(cellToBox(2, 4)).toBe(1);
expect(cellToBox(2, 5)).toBe(1);
});
});
describe('cells of third box', () => {
it('should return the third box', () => {
expect(cellToBox(0, 6)).toBe(2);
expect(cellToBox(0, 7)).toBe(2);
expect(cellToBox(0, 8)).toBe(2);
expect(cellToBox(1, 6)).toBe(2);
expect(cellToBox(1, 7)).toBe(2);
expect(cellToBox(1, 8)).toBe(2);
expect(cellToBox(2, 6)).toBe(2);
expect(cellToBox(2, 7)).toBe(2);
expect(cellToBox(2, 8)).toBe(2);
});
});
describe('cells of fourth box', () => {
it('should return the fourth box', () => {
expect(cellToBox(3, 0)).toBe(3);
expect(cellToBox(3, 1)).toBe(3);
expect(cellToBox(3, 2)).toBe(3);
expect(cellToBox(4, 0)).toBe(3);
expect(cellToBox(4, 1)).toBe(3);
expect(cellToBox(4, 2)).toBe(3);
expect(cellToBox(5, 0)).toBe(3);
expect(cellToBox(5, 1)).toBe(3);
expect(cellToBox(5, 2)).toBe(3);
});
});
describe('cells of fifth box', () => {
it('should return the fifth box', () => {
expect(cellToBox(3, 3)).toBe(4);
expect(cellToBox(3, 4)).toBe(4);
expect(cellToBox(3, 5)).toBe(4);
expect(cellToBox(4, 3)).toBe(4);
expect(cellToBox(4, 4)).toBe(4);
expect(cellToBox(4, 5)).toBe(4);
expect(cellToBox(5, 3)).toBe(4);
expect(cellToBox(5, 4)).toBe(4);
expect(cellToBox(5, 5)).toBe(4);
});
});
describe('cells of sixth box', () => {
it('should return the sixth box', () => {
expect(cellToBox(3, 6)).toBe(5);
expect(cellToBox(3, 7)).toBe(5);
expect(cellToBox(3, 8)).toBe(5);
expect(cellToBox(4, 6)).toBe(5);
expect(cellToBox(4, 7)).toBe(5);
expect(cellToBox(4, 8)).toBe(5);
expect(cellToBox(5, 6)).toBe(5);
expect(cellToBox(5, 7)).toBe(5);
expect(cellToBox(5, 8)).toBe(5);
});
});
describe('cells of seventh box', () => {
it('should return the seventh box', () => {
expect(cellToBox(6, 0)).toBe(6);
expect(cellToBox(6, 1)).toBe(6);
expect(cellToBox(6, 2)).toBe(6);
expect(cellToBox(7, 0)).toBe(6);
expect(cellToBox(7, 1)).toBe(6);
expect(cellToBox(7, 2)).toBe(6);
expect(cellToBox(8, 0)).toBe(6);
expect(cellToBox(8, 1)).toBe(6);
expect(cellToBox(8, 2)).toBe(6);
});
});
describe('cells of eigth box', () => {
it('should return the eigth box', () => {
expect(cellToBox(6, 3)).toBe(7);
expect(cellToBox(6, 4)).toBe(7);
expect(cellToBox(6, 5)).toBe(7);
expect(cellToBox(7, 3)).toBe(7);
expect(cellToBox(7, 4)).toBe(7);
expect(cellToBox(7, 5)).toBe(7);
expect(cellToBox(8, 3)).toBe(7);
expect(cellToBox(8, 4)).toBe(7);
expect(cellToBox(8, 5)).toBe(7);
});
});
describe('cells of ninth box', () => {
it('should return the ninth box', () => {
expect(cellToBox(6, 6)).toBe(8);
expect(cellToBox(6, 7)).toBe(8);
expect(cellToBox(6, 8)).toBe(8);
expect(cellToBox(7, 6)).toBe(8);
expect(cellToBox(7, 7)).toBe(8);
expect(cellToBox(7, 8)).toBe(8);
expect(cellToBox(8, 6)).toBe(8);
expect(cellToBox(8, 7)).toBe(8);
expect(cellToBox(8, 8)).toBe(8);
});
});