2023-02-01 23:53:54 +00:00
|
|
|
const findTheOldest = require('./findTheOldest-solution');
|
2022-02-20 19:07:44 +00:00
|
|
|
|
2023-02-01 23:53:54 +00:00
|
|
|
describe('findTheOldest', () => {
|
|
|
|
test('finds the oldest person!', () => {
|
2023-01-21 17:53:41 +00:00
|
|
|
const people = [
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Carly',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1942,
|
|
|
|
yearOfDeath: 1970,
|
|
|
|
},
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Ray',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1962,
|
|
|
|
yearOfDeath: 2011,
|
|
|
|
},
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Jane',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1912,
|
|
|
|
yearOfDeath: 1941,
|
|
|
|
},
|
|
|
|
];
|
2023-02-01 23:53:54 +00:00
|
|
|
expect(findTheOldest(people).name).toBe('Ray');
|
2023-01-21 17:53:41 +00:00
|
|
|
});
|
2023-02-01 23:58:58 +00:00
|
|
|
test('finds the oldest person if someone is still living', () => {
|
2023-01-21 17:53:41 +00:00
|
|
|
const people = [
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Carly',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 2018,
|
|
|
|
},
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Ray',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1962,
|
|
|
|
yearOfDeath: 2011,
|
|
|
|
},
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Jane',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1912,
|
|
|
|
yearOfDeath: 1941,
|
|
|
|
},
|
|
|
|
];
|
2023-02-01 23:53:54 +00:00
|
|
|
expect(findTheOldest(people).name).toBe('Ray');
|
2023-01-21 17:53:41 +00:00
|
|
|
});
|
2023-02-01 23:58:58 +00:00
|
|
|
test('finds the oldest person if the OLDEST is still living', () => {
|
2023-01-21 17:53:41 +00:00
|
|
|
const people = [
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Carly',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1066,
|
|
|
|
},
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Ray',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1962,
|
|
|
|
yearOfDeath: 2011,
|
|
|
|
},
|
|
|
|
{
|
2023-02-01 23:53:54 +00:00
|
|
|
name: 'Jane',
|
2023-01-21 17:53:41 +00:00
|
|
|
yearOfBirth: 1912,
|
|
|
|
yearOfDeath: 1941,
|
|
|
|
},
|
|
|
|
];
|
2023-02-01 23:53:54 +00:00
|
|
|
expect(findTheOldest(people).name).toBe('Carly');
|
2023-01-21 17:53:41 +00:00
|
|
|
});
|
2022-02-20 19:07:44 +00:00
|
|
|
});
|