-
Notifications
You must be signed in to change notification settings - Fork 634
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]); | ||
}); | ||
|
||
test('should return 1 for ages between the first and second threshould', | ||
() => { | ||
expect(getHumanAge(17, 17)).toEqual([1, 1]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
}); | ||
|
||
test('should handle large age values correctly', () => { | ||
expect(getHumanAge(100, 100)).toEqual([21, 17]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
}); | ||
|
||
test('should round down correctly for fractional years', () => { | ||
expect(getHumanAge(27, 27)).toEqual([2, 2]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
}); | ||
}); |
There was a problem hiding this comment.
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.