Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #600

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/getHumanAge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,28 @@ describe('getHumanAge', () => {
expect(getHumanAge)
.toBeInstanceOf(Function);
});

test('should return 0 for ages less than the first threshold', () => {
expect(getHumanAge(14, 14)).toEqual([0, 0]);
});

test('should return1for ages between the first and second thresholds', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in the test description: 'should return1for ages between the first and second thresholds'. It should be 'should return 1 for ages between the first and second thresholds' with a space between 'return' and '1'.

expect(getHumanAge(15, 15)).toEqual([1, 1]);
expect(getHumanAge(23, 23)).toEqual([1, 1]);
});

test('should handle different combinations of ages', () => {
expect(getHumanAge(24, 24)).toEqual([2, 2]);
expect(getHumanAge(28, 28)).toEqual([3, 2]);
expect(getHumanAge(100, 100)).toEqual([21, 17]);
});

test('should return 0 for negative ages', () => {
expect(getHumanAge(-5, -3)).toEqual([0, 0]);
});

test('should handle fractional ages', () => {
expect(getHumanAge(15.5, 15.5)).toEqual([1, 1]);
expect(getHumanAge(23.9, 23.9)).toEqual([1, 1]);
});
});