-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminesweeper.spec.js
More file actions
78 lines (66 loc) · 2.18 KB
/
minesweeper.spec.js
File metadata and controls
78 lines (66 loc) · 2.18 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { annotate } from './minesweeper';
describe(')', () => {
test('handles no rows', () => {
expect(annotate([])).toEqual([]);
});
xtest('handles no columns', () => {
expect(annotate([''])).toEqual(['']);
});
xtest('handles no mines', () => {
const input = [' ', ' ', ' '];
const expected = [' ', ' ', ' '];
expect(annotate(input)).toEqual(expected);
});
xtest('handles minefield with only mines', () => {
const input = ['***', '***', '***'];
const expected = ['***', '***', '***'];
expect(annotate(input)).toEqual(expected);
});
xtest('handles mine surrounded by spaces', () => {
const input = [' ', ' * ', ' '];
const expected = ['111', '1*1', '111'];
expect(annotate(input)).toEqual(expected);
});
xtest('handles space surrounded by mines', () => {
const input = ['***', '* *', '***'];
const expected = ['***', '*8*', '***'];
expect(annotate(input)).toEqual(expected);
});
xtest('handles horizontal line', () => {
const input = [' * * '];
const expected = ['1*2*1'];
expect(annotate(input)).toEqual(expected);
});
xtest('handles horizontal line, mines at edges', () => {
const input = ['* *'];
const expected = ['*1 1*'];
expect(annotate(input)).toEqual(expected);
});
xtest('handles vertical line', () => {
const input = [' ', '*', ' ', '*', ' '];
const expected = ['1', '*', '2', '*', '1'];
expect(annotate(input)).toEqual(expected);
});
xtest('handles vertical line, mines at edges', () => {
const input = ['*', ' ', ' ', ' ', '*'];
const expected = ['*', '1', ' ', '1', '*'];
expect(annotate(input)).toEqual(expected);
});
xtest('handles cross', () => {
const input = [' * ', ' * ', '*****', ' * ', ' * '];
const expected = [' 2*2 ', '25*52', '*****', '25*52', ' 2*2 '];
expect(annotate(input)).toEqual(expected);
});
xtest('handles large minefield', () => {
const input = [' * * ', ' * ', ' * ', ' * *', ' * * ', ' '];
const expected = [
'1*22*1',
'12*322',
' 123*2',
'112*4*',
'1*22*2',
'111111',
];
expect(annotate(input)).toEqual(expected);
});
});