From 9ed28aba8bbe12e95f96b2390da4cc2ea1e84dbd Mon Sep 17 00:00:00 2001 From: Pavlo Petrashevskyi Date: Sat, 2 Nov 2024 10:16:32 +0200 Subject: [PATCH 1/2] tests for getHumanAge function were added --- src/getHumanAge.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/getHumanAge.test.js b/src/getHumanAge.test.js index 6ce3e586..beea65f5 100644 --- a/src/getHumanAge.test.js +++ b/src/getHumanAge.test.js @@ -7,4 +7,21 @@ describe('getHumanAge', () => { expect(getHumanAge) .toBeInstanceOf(Function); }); + + test('animals` human age should be 0 if their own age < 15', () => { + expect(getHumanAge(0, 14)).toEqual([0, 0]); + }); + + test('animals` human age should be 1 if their own age > 14 and < 24', () => { + expect(getHumanAge(15, 23)).toEqual([1, 1]); + }); + + test(`cat's age should add 1 every 4 years after 23 years old + dog's age should add 1 every 5 years after 23 years old`, () => { + expect(getHumanAge(24, 24)).toEqual([2, 2]); + expect(getHumanAge(27, 28)).toEqual([2, 2]); + expect(getHumanAge(31, 33)).toEqual([3, 3]); + expect(getHumanAge(59, 59)).toEqual([10, 9]); + expect(getHumanAge(47, 88)).toEqual([7, 14]); + }); }); From 83f2ddfe6089ab73226e8c6b88b8d8d287f20963 Mon Sep 17 00:00:00 2001 From: Pavlo Petrashevskyi Date: Sat, 2 Nov 2024 10:57:00 +0200 Subject: [PATCH 2/2] description for tests were changed --- src/getHumanAge.test.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/getHumanAge.test.js b/src/getHumanAge.test.js index beea65f5..7e8d7f5c 100644 --- a/src/getHumanAge.test.js +++ b/src/getHumanAge.test.js @@ -8,16 +8,18 @@ describe('getHumanAge', () => { .toBeInstanceOf(Function); }); - test('animals` human age should be 0 if their own age < 15', () => { + test(`Should return 0 for animals' human age, + if animals' age less than 15`, () => { expect(getHumanAge(0, 14)).toEqual([0, 0]); }); - test('animals` human age should be 1 if their own age > 14 and < 24', () => { + test(`Should return 1 for animals' human age, + if animals' age greater than 14 and less than 24`, () => { expect(getHumanAge(15, 23)).toEqual([1, 1]); }); - test(`cat's age should add 1 every 4 years after 23 years old - dog's age should add 1 every 5 years after 23 years old`, () => { + test(`Should add 1 cat's human year for every 4 cat's years and + Should add 1 dog's human year for every 5 dog's years`, () => { expect(getHumanAge(24, 24)).toEqual([2, 2]); expect(getHumanAge(27, 28)).toEqual([2, 2]); expect(getHumanAge(31, 33)).toEqual([3, 3]);