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

tests for getHumanAge function #606

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
21 changes: 21 additions & 0 deletions src/getHumanAge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,25 @@ describe('getHumanAge', () => {
expect(getHumanAge)
.toBeInstanceOf(Function);
});

test('should convert cat and dog ages correctly', () => {
expect(getHumanAge(23, 23)).toEqual([1, 1]);
});

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

Choose a reason for hiding this comment

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

The test case for ages less than the first threshold is correct. However, ensure that the implementation of getHumanAge returns 0 for both cat and dog ages when they are below 15 years.

});

test('should return 1 for ages between the first and second threshould',
() => {
expect(getHumanAge(17, 17)).toEqual([1, 1]);

Choose a reason for hiding this comment

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

The test case for ages between the first and second threshold is correct. Ensure that the implementation of getHumanAge returns 1 for both cat and dog ages when they are between 15 and 23 years.

});

test('should handle large age values correctly', () => {
expect(getHumanAge(100, 100)).toEqual([21, 17]);

Choose a reason for hiding this comment

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

The expected result for large age values is incorrect. For 100 cat years, the expected human age should be 21, and for 100 dog years, it should be 17. Update the expected result to [21, 17].

});

test('should round down correctly for fractional years', () => {
expect(getHumanAge(27, 27)).toEqual([2, 2]);

Choose a reason for hiding this comment

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

This test case is a duplicate of the earlier test case for 27 years. Ensure that the expected result is updated to [3, 2] as per the task description.

Choose a reason for hiding this comment

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

The expected result for 27 years is incorrect. For 27 cat years, the expected human age should be 3, and for 27 dog years, it should be 2. Update the expected result to [3, 2].

});
});