Jasmine factorial test
by jessekinsman
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine.css">
<script src="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine.js"></script>
<script src="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine-html.js"></script>
JavaScript
function factorial (n) {
if (n < 2) return 1;
return n * factorial(n-1);
}
// unit tests
// do not modify the below code
describe('factorial', function() {
it('should do factorials', () => {
expect(factorial(1)).toEqual(1);
expect(factorial(2)).toEqual(2);
expect(factorial(3)).toEqual(6);
expect(factorial(10)).toEqual(3628800);
});
});
// load jasmine htmlReporter
(function() {
var env = jasmine.getEnv();
env.addReporter(new jasmine.HtmlReporter());
env.execute();
}());