-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise-8.test.js
More file actions
32 lines (27 loc) · 990 Bytes
/
exercise-8.test.js
File metadata and controls
32 lines (27 loc) · 990 Bytes
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
const exerciseEight = require('./exercise-8');
const countryData = require('./country-data');
describe('Exercise 8', () => {
test('Uses every method', () => {
const inputArray = [];
const everySpy = jest.spyOn(inputArray, 'every');
exerciseEight(inputArray);
expect(everySpy).toHaveBeenCalled();
})
test('Does not modify input array', () => {
const inputArray = [...countryData];
exerciseEight(inputArray);
expect(inputArray).toEqual(countryData);
})
test('Returns true if threshold below all population figures', () => {
const result = exerciseEight(countryData, 1);
expect(result).toBe(true)
})
test('Returns false if threshold is between population figures', () => {
const result = exerciseEight(countryData, 200000);
expect(result).toBe(false)
})
test('Returns false if threshold is above all population figures', () => {
const result = exerciseEight(countryData, 1000000000);
expect(result).toBe(false)
})
})