From 75ae97e78ef4e80493340602c1f2fd4a4e4568c0 Mon Sep 17 00:00:00 2001 From: yaroslavdashko Date: Tue, 8 Jul 2025 22:38:02 +0300 Subject: [PATCH 1/2] Solution --- src/arrayReverse.test.js | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index cf8ac47..b8b9eb7 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -1,20 +1,48 @@ 'use strict'; -describe(`Function 'arrayReverse':`, () => { +describe("Function 'arrayReverse':", () => { const arrayReverse = require('./arrayReverse'); - it(`should be declared`, () => { + it('should be declared', () => { expect(arrayReverse).toBeInstanceOf(Function); }); - it(`should return an array`, () => { + it('should return an array', () => { + const result = arrayReverse(['abc']); + expect(Array.isArray(result)).toBe(true); }); - it(`should return an empty string - if original array consists of an empty string`, () => { + it('should reverse a single word', () => { + expect(arrayReverse(['Hell0'])).toEqual(['0lleH']); + }); + + it('should reverse multiple words keeping their lengths', () => { expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); }); - // write more tests here + it('should handle an array of multiple small words', () => { + expect(arrayReverse(['I', 'am', 'a', 'student!'])).toEqual([ + '!', + 'tn', + 'e', + 'dutsamaI', + ]); + }); + + it('should return arr with empty str if array consists an empty string', () => { + expect(arrayReverse([''])).toEqual(['']); + }); + + it('should handle empty array', () => { + expect(arrayReverse([])).toEqual([]); + }); + + it('should handle array with multiple empty strings', () => { + expect(arrayReverse(['', '', ''])).toEqual(['', '', '']); + }); + + it('should correctly reverse str with special chars and digits', () => { + expect(arrayReverse(['12$', '%^&'])).toEqual(['&^%', '$21']); + }); }); From 465fcfb3e91d69902255006a73a279ec01e34d70 Mon Sep 17 00:00:00 2001 From: yaroslavdashko Date: Tue, 8 Jul 2025 22:42:09 +0300 Subject: [PATCH 2/2] Solution --- src/arrayReverse.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index b8b9eb7..16384b5 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -30,7 +30,7 @@ describe("Function 'arrayReverse':", () => { ]); }); - it('should return arr with empty str if array consists an empty string', () => { + it('should return arr with empty str if arr consists empty string', () => { expect(arrayReverse([''])).toEqual(['']); });