forked from loiane/javascript-datastructures-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactorial.spec.ts
26 lines (23 loc) · 858 Bytes
/
factorial.spec.ts
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
import 'mocha';
import { expect } from 'chai';
import { factorialIterative, factorial } from '../../../src/ts/index';
describe('Factorial', () => {
it('Iterative Factorial', () => {
expect(factorialIterative(-1)).to.equal(undefined);
expect(factorialIterative(0)).to.equal(1);
expect(factorialIterative(1)).to.equal(1);
expect(factorialIterative(2)).to.equal(2);
expect(factorialIterative(3)).to.equal(6);
expect(factorialIterative(4)).to.equal(24);
expect(factorialIterative(5)).to.equal(120);
});
it('Recursive Factorial', () => {
expect(factorial(-1)).to.equal(undefined);
expect(factorial(0)).to.equal(1);
expect(factorial(1)).to.equal(1);
expect(factorial(2)).to.equal(2);
expect(factorial(3)).to.equal(6);
expect(factorial(4)).to.equal(24);
expect(factorial(5)).to.equal(120);
});
});