forked from afropolymath/javascript-tdd-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
69 lines (66 loc) · 2.45 KB
/
tests.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
'use strict'
var chai = require('chai');
var assert = chai.assert;
var lib = require('./lib/sum_of_primes.js');
describe("Test that constants are computed properly", function() {
it("should return 'Invalid input. A number was expected but a string was giving.' if 'str' is given", function() {
assert(
lib.sumOfPrimes('str') == "Invalid input. A number was expected but a string was giving."
);
});
it("It should return 'Invalid input. A number was expected but an Object was giving.' if parameter given is an array", function() {
assert(
lib.sumOfPrimes([1,2,3]) == "Invalid input. A number was expected but an Object was giving."
);
});
it("It should return 'Invalid input. A number was expected but an Object was giving.' if parameter given is an object", function() {
assert(
lib.sumOfPrimes({x:9}) == "Invalid input. A number was expected but an Object was giving."
);
});
it("should give 17 if 10 is the given input", function() {
assert(
lib.sumOfPrimes(10) == 17
);
});
it("should return a number as the result if given a valid number as an input", function() {
assert(
typeof(lib.sumOfPrimes(10)) == 'number'
);
});
it("should return 'Invalid input. Input must be greater than 1' if parameter given is 0", function() {
assert(
lib.sumOfPrimes(0) == "Invalid input. Input must be greater than 1"
);
});
it("should return 'Invalid input. Input must be greater than 1' if parameter given is 1", function() {
assert(
lib.sumOfPrimes(1) == "Invalid input. Input must be greater than 1"
);
});
it("should return 2 if parameter given is 2", function() {
assert(
lib.sumOfPrimes(2) == 2
);
});
it("should return 'Invalid input. Only one input is required' if number of parameters given is more than 1", function() {
assert(
lib.sumOfPrimes(89,5) == "Invalid input. Only one input is required"
);
});
it("should return 'Invalid input. Input must be greater than 1' if given is a negative number", function() {
assert(
lib.sumOfPrimes(-7) == "Invalid input. Input must be greater than 1"
);
});
it("should return 381 if given 56 as your parameter", function() {
assert(
lib.sumOfPrimes(56) == 381
);
});
it("should return 'Invalid input. Only one input is required' if given no parameter is given", function() {
assert(
lib.sumOfPrimes() == "Invalid input. Only one input is required"
);
});
});