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

add tests for cat and dogs years #630

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
28 changes: 26 additions & 2 deletions src/getHumanAge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,31 @@ describe('getHumanAge', () => {
const { getHumanAge } = require('./getHumanAge');

test('should be declared', () => {
expect(getHumanAge)
.toBeInstanceOf(Function);
expect(getHumanAge).toBeInstanceOf(Function);
});

test('should return [0, 0] for ages less then 15', () => {

Choose a reason for hiding this comment

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

Typo in the test description: 'less then' should be 'less than'.

expect(getHumanAge(10, 10)).toEqual([0, 0]);
});

test('should return [1, 1] for ages between 15 and 23 ', () => {
expect(getHumanAge(15, 20)).toEqual([1, 1]);
});

test('should return [2, 2] for ages of exactly 24', () => {
expect(getHumanAge(24, 24)).toEqual([2, 2]);
});

test('should calculate additional years correctly for cats and dogs', () => {
expect(getHumanAge(28, 29)).toEqual([3, 3]);
});

test('should handle mixed ages correctly', () => {
expect(getHumanAge(18, 10)).toEqual([1, 0]);
});

test('should handle edge cases correctly', () => {
expect(getHumanAge(15, 15)).toEqual([1, 1]);
expect(getHumanAge(25, 25)).toEqual([2, 2]);
});
});