-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise-9.test.js
More file actions
32 lines (27 loc) · 964 Bytes
/
exercise-9.test.js
File metadata and controls
32 lines (27 loc) · 964 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 exerciseNine = require('./exercise-9');
const countryData = require('./country-data');
describe('Exercise 9', () => {
test('Uses some method', () => {
const inputArray = [];
const someSpy = jest.spyOn(inputArray, 'some');
exerciseNine(inputArray);
expect(someSpy).toHaveBeenCalled();
})
test('Does not modify input array', () => {
const inputArray = [...countryData];
exerciseNine(inputArray);
expect(inputArray).toEqual(countryData);
})
test('Returns true when there is one matching entry', () => {
const result = exerciseNine(countryData, 'Europe');
expect(result).toBe(true)
})
test('Returns true when there is two matching entries', () => {
const result = exerciseNine(countryData, 'Africa');
expect(result).toBe(true)
})
test('Returns false when there is no matching entries', () => {
const result = exerciseNine(countryData, 'South America');
expect(result).toBe(false)
})
})