From 395b221cdac3a8c1bc1b79be763959e0a2d0300c Mon Sep 17 00:00:00 2001 From: Oleksii-Ivan Stetsyk Date: Thu, 2 Oct 2025 18:16:15 +0300 Subject: [PATCH 1/2] add tests for arrayReverse function --- src/arrayReverse.test.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index cf8ac47..f76d5a6 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -8,13 +8,30 @@ describe(`Function 'arrayReverse':`, () => { }); it(`should return an array`, () => { + expect(arrayReverse(['Mate', 'Academy'])).toBeInstanceOf(Array); + }); + + it(`should handle empty strings in the array`, () => { + expect(arrayReverse(['', 'Academy'])).toEqual(['', 'ymedacA']); + }); + it('should return an empty array if original array is empty', () => { + expect(arrayReverse([])).toEqual([]); }); - it(`should return an empty string - if original array consists of an empty string`, () => { + it('should return an array with reversed strings', () => { expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); }); - // write more tests here + it('should preserve original array length', () => { + expect(arrayReverse(['Mate', 'Academy']).length).toEqual(2); + }); + + it('should return an array with empty strings reversed', () => { + expect(arrayReverse(['', ''])).toEqual(['', '']); + }); + + it('should return an array with a single reversed string', () => { + expect(arrayReverse(['Mate'])).toEqual(['etaM']); + }); }); From cc3afed08ef27fcda89e24259db89a6d8a13462d Mon Sep 17 00:00:00 2001 From: Oleksii-Ivan Stetsyk Date: Thu, 2 Oct 2025 18:26:28 +0300 Subject: [PATCH 2/2] update tests --- src/arrayReverse.test.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index f76d5a6..946cf17 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -1,17 +1,17 @@ 'use strict'; -describe(`Function 'arrayReverse':`, () => { - const arrayReverse = require('./arrayReverse'); +const arrayReverse = require('./arrayReverse'); - it(`should be declared`, () => { +describe(`Function 'arrayReverse':`, () => { + it('should be declared', () => { expect(arrayReverse).toBeInstanceOf(Function); }); - it(`should return an array`, () => { + it('should return an array', () => { expect(arrayReverse(['Mate', 'Academy'])).toBeInstanceOf(Array); }); - it(`should handle empty strings in the array`, () => { + it('should handle empty strings in the array', () => { expect(arrayReverse(['', 'Academy'])).toEqual(['', 'ymedacA']); }); @@ -34,4 +34,22 @@ describe(`Function 'arrayReverse':`, () => { it('should return an array with a single reversed string', () => { expect(arrayReverse(['Mate'])).toEqual(['etaM']); }); + + it("should handle ['Hell0'] -> ['0lleH']", () => { + expect(arrayReverse(['Hell0'])).toEqual(['0lleH']); + }); + + it("should handle ['I','am','a','student!']" + + "->['!', 'tn', 'e', 'dutsamaI']", () => { + expect(arrayReverse(['I', 'am', 'a', 'student!'])).toEqual([ + '!', + 'tn', + 'e', + 'dutsamaI', + ]); + }); + + it("should handle ['A'] -> ['A']", () => { + expect(arrayReverse(['A'])).toEqual(['A']); + }); });