forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartition.test.js
More file actions
24 lines (20 loc) · 796 Bytes
/
Partition.test.js
File metadata and controls
24 lines (20 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { canPartition } from '../Partition'
describe('Partition (Recursive)', () => {
it('expects to return true for an array that can be partitioned', () => {
const result = canPartition([1, 5, 11, 5])
expect(result).toBe(true)
})
it('expects to return false for an array that cannot be partitioned', () => {
const result = canPartition([1, 2, 3, 5])
expect(result).toBe(false)
})
it('expects to return true for an empty array (0 elements)', () => {
const result = canPartition([])
expect(result).toBe(true)
})
it('Throw Error for Invalid Input', () => {
expect(() => canPartition(123)).toThrow('Invalid Input')
expect(() => canPartition(null)).toThrow('Invalid Input')
expect(() => canPartition(undefined)).toThrow('Invalid Input')
})
})