|
1 | 1 | import { islands } from '../NumberOfIslands'
|
2 | 2 |
|
3 | 3 | describe('Number of Islands', () => {
|
4 |
| - test('Test Case 1', () => { |
| 4 | + test('Graph with three islands', () => { |
5 | 5 | const graph = [
|
6 | 6 | ['1', '1', '0', '0', '0'],
|
7 | 7 | ['1', '1', '0', '0', '0'],
|
8 | 8 | ['0', '0', '1', '0', '0'],
|
9 | 9 | ['0', '0', '0', '1', '1']
|
10 | 10 | ]
|
11 |
| - const result = islands(graph) |
12 |
| - expect(result).toBe(3) |
| 11 | + expect(islands(graph)).toBe(3) |
13 | 12 | })
|
14 | 13 |
|
15 |
| - test('Test Case 2', () => { |
| 14 | + test('Graph with only one island', () => { |
16 | 15 | const graph = [
|
17 | 16 | ['1', '1'],
|
18 | 17 | ['1', '1'],
|
19 | 18 | ['0', '0'],
|
20 | 19 | ['0', '0']
|
21 | 20 | ]
|
22 |
| - const result = islands(graph) |
23 |
| - expect(result).toBe(1) |
| 21 | + expect(islands(graph)).toBe(1) |
24 | 22 | })
|
25 | 23 |
|
26 |
| - test('Test Case 3', () => { |
| 24 | + test('No islands', () => { |
27 | 25 | const graph = [
|
28 | 26 | ['0', '0'],
|
29 | 27 | ['0', '0']
|
30 | 28 | ]
|
31 |
| - const result = islands(graph) |
32 |
| - expect(result).toBe(0) |
| 29 | + expect(islands(graph)).toBe(0) |
33 | 30 | })
|
34 | 31 | })
|
0 commit comments