Skip to content

Commit 1005207

Browse files
committed
test: add test for UniquePaths2.js
1 parent d648030 commit 1005207

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { uniquePaths2 } from '../UniquePaths2'
2+
3+
describe('Unique Paths2', () => {
4+
// Should return number of ways, taken into account the obstacles
5+
test('Case 1: there are obstacles in the way', () => {
6+
expect(uniquePaths2([[0, 0, 0], [0, 1, 0], [0, 0, 0]])).toEqual(2)
7+
expect(uniquePaths2([[0, 0, 0], [0, 1, 0], [0, 0, 0], [1, 0, 0]])).toEqual(3)
8+
})
9+
// Should return number of all possible ways to reach right-bottom corner
10+
test('Case 2: there are no obstacles in the way', () => {
11+
expect(uniquePaths2([[0, 0, 0], [0, 0, 0], [0, 0, 0]])).toEqual(6)
12+
expect(uniquePaths2([[0, 0, 0], [0, 0, 0]])).toEqual(3)
13+
})
14+
// Should throw an exception b/c input data has wrong type
15+
test('Case 3: there are wrong type of input data', () => {
16+
expect(() => uniquePaths2('wrong input')).toThrow()
17+
expect(() => uniquePaths2(100)).toThrow()
18+
})
19+
})

0 commit comments

Comments
 (0)