mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 19:17:33 +08:00
20 lines
646 B
JavaScript
20 lines
646 B
JavaScript
import { factorial } from '../Factorial'
|
|
|
|
describe('Factorial', () => {
|
|
it('should return factorial 1 for value "0"', () => {
|
|
expect(factorial(0)).toBe(1)
|
|
})
|
|
|
|
it('should return factorial 120 for value "5"', () => {
|
|
expect(factorial(5)).toBe(120)
|
|
})
|
|
|
|
it('Throw Error for Invalid Input', () => {
|
|
expect(() => factorial('-')).toThrow('Not a Whole Number')
|
|
expect(() => factorial(null)).toThrow('Not a Whole Number')
|
|
expect(() => factorial(undefined)).toThrow('Not a Whole Number')
|
|
expect(() => factorial(3.142)).toThrow('Not a Whole Number')
|
|
expect(() => factorial(-1)).toThrow('Not a Positive Number')
|
|
})
|
|
})
|