-
Notifications
You must be signed in to change notification settings - Fork 0
/
some-every.test.js
65 lines (60 loc) · 2.47 KB
/
some-every.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
describe("#hasOddNumber", function() {
it("returns true if there is at least one odd number in the array", function() {
expect(hasOddNumber([1, 2, 2, 2, 2, 2, 4])).toEqual(true);
});
it("returns false if there are no odd numbers in the array", function() {
expect(hasOddNumber([2, 2, 2, 2, 2, 4])).toEqual(false);
});
});
describe("#hasAZero", function() {
it("returns true if the number contains at least one 0", function() {
expect(hasAZero(33321232131012)).toEqual(true);
});
it("returns false if the number does not have any zeros", function() {
expect(hasAZero(1212121)).toEqual(false);
});
});
describe("#hasOnlyOddNumbers", function() {
it("returns true if every number in the array is odd", function() {
expect(hasOnlyOddNumbers([1, 3, 5, 7])).toEqual(true);
});
it("returns false if there is one or more even numbers ", function() {
expect(hasOnlyOddNumbers([1, 2, 3, 5, 7])).toEqual(false);
});
});
describe("#hasNoDuplicates", function() {
it("returns true if there are no duplicates in the array", function() {
expect(hasNoDuplicates([1, 2, 3, 1])).toEqual(false);
});
it("returns false if there are duplicates in the array", function() {
expect(hasNoDuplicates([1, 2, 3])).toEqual(true);
});
});
describe("#hasCertainKey", function() {
var arr = [
{ first: "Elie", last: "Schoppik" },
{ first: "Tim", last: "Garcia", isCatOwner: true },
{ first: "Matt", last: "Lane" },
{ first: "Colt", last: "Steele", isCatOwner: true }
];
it("returns true if every object in the array contains a certain key", function() {
expect(hasCertainKey(arr, "first")).toEqual(true);
});
it("returns false if every object in the array does not contain a certain key", function() {
expect(hasCertainKey(arr, "isCatOwner")).toEqual(false);
});
});
describe("#hasCertainValue", function() {
var arr = [
{ title: "Instructor", first: "Elie", last: "Schoppik" },
{ title: "Instructor", first: "Tim", last: "Garcia", isCatOwner: true },
{ title: "Instructor", first: "Matt", last: "Lane" },
{ title: "Instructor", first: "Colt", last: "Steele", isCatOwner: true }
];
it("returns true if every object in an array has the same value for some key", function() {
expect(hasCertainValue(arr, "title", "Instructor")).toEqual(true);
});
it("returns false if every object in an array does not have the same value for some key", function() {
expect(hasCertainValue(arr, "first", "Elie")).toEqual(false);
});
});