Testing Factorial Algorithm Implementation in javascript-algorithms
This test suite validates the factorial algorithm implementation using Jest unit tests. The tests verify correct factorial calculations for various input numbers, including edge cases like 0 and 1, as well as larger numbers up to 10.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
trekhleb/javascript-algorithms
src/algorithms/math/factorial/__test__/factorial.test.js
import factorial from '../factorial';
describe('factorial', () => {
it('should calculate factorial', () => {
expect(factorial(0)).toBe(1);
expect(factorial(1)).toBe(1);
expect(factorial(5)).toBe(120);
expect(factorial(8)).toBe(40320);
expect(factorial(10)).toBe(3628800);
});
});