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 #612

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

test('should return an array with 2 integers', () => {
const result = getHumanAge(19, 19);

expect(Array.isArray(result)).toBe(true);
expect(result.length).toBe(2);

for (const value of result) {
expect(Number.isInteger(value)).toBe(true);
}
});

test('should return [0, 0] when both parameters are 0', () => {
expect(getHumanAge(0, 0)
).toEqual([0, 0]);
});

test('should ignore decimal part of the input', () => {
expect(getHumanAge(15.7, 15.9)).toEqual([1, 1]);
Comment on lines +27 to +28

Choose a reason for hiding this comment

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

The test case for ignoring the decimal part of the input (getHumanAge(15.7, 15.9)) might not be necessary if the function is expected to handle only integer inputs, as per the task description. Consider whether this test aligns with the intended functionality of getHumanAge.

});

test(' should return [2, 2] for boundary value 24 years', () => {
expect(getHumanAge(24, 24)).toEqual([2, 2]);
});

test('should return [3, 2] for boundary value 28 years (cat)', () => {
expect(getHumanAge(28, 28)).toEqual([3, 2]);
});

test('Boundary value for dog 3(29) years', () => {
expect(getHumanAge(29, 29)).toEqual([3, 3]);
});

test('should handle high numbers', () => {
expect(getHumanAge(150, 200)).toEqual([33, 37]);
});

test('should handle different cat and dog ages', () => {
expect(getHumanAge(30, 18)).toEqual([3, 1]);
});
});