-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise-7.test.js
More file actions
27 lines (23 loc) · 851 Bytes
/
exercise-7.test.js
File metadata and controls
27 lines (23 loc) · 851 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
const exerciseSeven = require('./exercise-7');
const countryData = require('./country-data');
describe('Exercise 7', () => {
test('Uses find method', () => {
const inputArray = [];
const findSpy = jest.spyOn(inputArray, 'find');
exerciseSeven(inputArray);
expect(findSpy).toHaveBeenCalled();
})
test('Does not modify input array', () => {
const inputArray = [...countryData];
exerciseSeven(inputArray);
expect(inputArray).toEqual(countryData);
})
test('Returns correct object if United Kingdom is passed', () => {
const result = exerciseSeven(countryData, 'United Kingdom');
expect(result).toEqual(countryData[0])
})
test('Returns undefined if name is not present in array', () => {
const result = exerciseSeven(countryData, 'Non-existant land!');
expect(result).toEqual(undefined)
})
})