-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfloodFill.test.js
58 lines (49 loc) · 926 Bytes
/
floodFill.test.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
const floodFill = require('./floodFill')
test('Example 1', () => {
const image = [
[1, 1, 1],
[1, 1, 0],
[1, 0, 1]
]
const sr = 1
const sc = 1
const newColor = 2
const result = floodFill(image, sr, sc, newColor)
expect(result).toStrictEqual([
[2, 2, 2],
[2, 2, 0],
[2, 0, 1]
])
})
test('new color is the same as start color', () => {
const image = [
[1, 1, 1],
[1, 1, 0],
[1, 0, 1]
]
const sr = 1
const sc = 1
const newColor = 1
const result = floodFill(image, sr, sc, newColor)
expect(result).toStrictEqual([
[1, 1, 1],
[1, 1, 0],
[1, 0, 1]
])
})
test('change whole image', () => {
const image = [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
const sr = 1
const sc = 1
const newColor = 2
const result = floodFill(image, sr, sc, newColor)
expect(result).toStrictEqual([
[2, 2, 2],
[2, 2, 2],
[2, 2, 2]
])
})