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