forked from loiane/javascript-datastructures-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprimality-test.spec.ts
30 lines (25 loc) · 917 Bytes
/
primality-test.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
27
28
29
30
import 'mocha';
import { expect } from 'chai';
import { isPrime, testPrime, isPrime2 } from '../../../../src/ts/index';
describe('Primality Tests', () => {
it('returns if the number is prime or not - isPrime', () => {
testIsPrime(isPrime);
});
it('returns if the number is prime or not - testPrime', () => {
testIsPrime(testPrime);
});
it('returns if the number is prime or not - isPrime2', () => {
testIsPrime(isPrime2);
});
function testIsPrime(primeFunction) {
expect(primeFunction(-1)).to.equal(false);
expect(primeFunction(0)).to.equal(false);
expect(primeFunction(1)).to.equal(false);
expect(primeFunction(2)).to.equal(true);
expect(primeFunction(3)).to.equal(true);
expect(primeFunction(4)).to.equal(false);
expect(primeFunction(5)).to.equal(true);
expect(primeFunction(10)).to.equal(false);
expect(primeFunction(113)).to.equal(true);
}
});