mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-06-05 15:09:09 +09:00
f3a6283a93
fix ambiguity in test description , old was 'finds the person with the greatest age if someone is still living.' remove redundant test that checks for 'finds the person with the greatest age if the OLDEST is still living' since both this and the above test for ability to check if there is no death year field.
44 lines
927 B
JavaScript
44 lines
927 B
JavaScript
const findTheOldest = require('./findTheOldest')
|
|
|
|
describe('findTheOldest', () => {
|
|
test('finds the person with the greatest age!', () => {
|
|
const people = [
|
|
{
|
|
name: "Carly",
|
|
yearOfBirth: 1942,
|
|
yearOfDeath: 1970,
|
|
},
|
|
{
|
|
name: "Ray",
|
|
yearOfBirth: 1962,
|
|
yearOfDeath: 2011,
|
|
},
|
|
{
|
|
name: "Jane",
|
|
yearOfBirth: 1912,
|
|
yearOfDeath: 1941,
|
|
},
|
|
]
|
|
expect(findTheOldest(people).name).toBe('Ray');
|
|
});
|
|
test('finds the oldest person if yearOfDeath field is not present', () => {
|
|
const people = [
|
|
{
|
|
name: "Carly",
|
|
yearOfBirth: 1066,
|
|
},
|
|
{
|
|
name: "Ray",
|
|
yearOfBirth: 1962,
|
|
yearOfDeath: 2011,
|
|
},
|
|
{
|
|
name: "Jane",
|
|
yearOfBirth: 1912,
|
|
yearOfDeath: 1941,
|
|
},
|
|
]
|
|
expect(findTheOldest(people).name).toBe('Carly');
|
|
});
|
|
});
|