-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimeFactors.test.js
80 lines (79 loc) · 3.03 KB
/
PrimeFactors.test.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const primeFactors = require('./PrimeFactors');
describe("Prime factors", () => {
test('Prime factors of 1 should return empty array', () => {
// arrange and act
var result = primeFactors(1);
// assert
expect(result).toStrictEqual([]);
});
test('Prime factors of 2 should return [2]', () => {
// arrange and act
var result = primeFactors(2);
// assert
expect(result).toStrictEqual([2]);
});
test('Prime factors of 3 should return [3]', () => {
// arrange and act
var result = primeFactors(3);
// assert
expect(result).toStrictEqual([3]);
});
test('Prime factors of 4 should return [2,2]', () => {
// arrange and act
var result = primeFactors(4);
// assert
expect(result).toStrictEqual([2,2]);
});
test('Prime factors of 5 should return [5]', () => {
// arrange and act
var result = primeFactors(5);
// assert
expect(result).toStrictEqual([5]);
});
test('Prime factors of 6 should return [2,3]', () => {
// arrange and act
var result = primeFactors(6);
// assert
expect(result).toStrictEqual([2,3]);
});
test('Prime factors of 7 should return [7]', () => {
// arrange and act
var result = primeFactors(7);
// assert
expect(result).toStrictEqual([7]);
});
test('Prime factors of 8 should return [2,2,2]', () => {
// arrange and act
var result = primeFactors(8);
// assert
expect(result).toStrictEqual([2,2,2]);
});
test('Prime factors of 9 should return [3,3]', () => {
// arrange and act
var result = primeFactors(9);
// assert
expect(result).toStrictEqual([3,3]);
});
test('Prime factors of 10 should return [2,5]', () => {
// arrange and act
var result = primeFactors(10);
// assert
expect(result).toStrictEqual([2,5]);
});
test('Prime factors of 2*5*6*8*27*11*13 should return [2,2,2,2,2,3,3,3,3,5,11,13]', () => {
var result = primeFactors(2*5*6*8*27*11*13);
expect(result).toStrictEqual([2,2,2,2,2,3,3,3,3,5,11,13]);
});
test('Prime factors of "a" should return "Input must be a finite integer greater than or equal to 1"', () => {
var result = primeFactors('a');
expect(result).toStrictEqual("Input must be a finite integer greater than or equal to 1");
});
test('Prime factors of "a" should return "Input must be a finite integer greater than or equal to 1"', () => {
var result = primeFactors(1/0);
expect(result).toStrictEqual("Input must be a finite integer greater than or equal to 1");
});
test('Prime factors of "a" should return "Input must be a finite integer greater than or equal to 1"', () => {
var result = primeFactors(-1);
expect(result).toStrictEqual("Input must be a finite integer greater than or equal to 1");
});
})