forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinomialCoefficient.test.js
29 lines (23 loc) · 988 Bytes
/
BinomialCoefficient.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
import { findBinomialCoefficient } from '../BinomialCoefficient.js'
describe('Testing findBinomialCoefficient function', () => {
it('should return 56', () => {
const binomialCoefficient = findBinomialCoefficient(8, 3)
expect(binomialCoefficient).toBe(56)
})
it('should return 10', () => {
const binomialCoefficient = findBinomialCoefficient(5, 2)
expect(binomialCoefficient).toBe(10)
})
it('should throw error when supplied arguments other than number', () => {
expect(() => { findBinomialCoefficient('eight', 'three') }).toThrow(Error)
})
it('should throw error when n is less than zero', () => {
expect(() => { findBinomialCoefficient(-1, 3) }).toThrow(Error)
})
it('should throw error when k is less than zero', () => {
expect(() => { findBinomialCoefficient(1, -3) }).toThrow(Error)
})
it('should throw error when n and k are less than zero', () => {
expect(() => { findBinomialCoefficient(-1, -3) }).toThrow(Error)
})
})