From 12e60c0ab695c8fb0f6c734051b7b8cbfa89d610 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Fri, 10 Jul 2026 09:29:21 +0300 Subject: [PATCH 1/2] added tests --- src/arrayReverse.test.js | 41 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index 6e7ca36..1835a60 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -7,12 +7,45 @@ describe(`Function 'arrayReverse':`, () => { expect(arrayReverse).toBeInstanceOf(Function); }); - it(`should return an array`, () => {}); + it(`should return an array`, () => { + const result = arrayReverse(['test']); - it(`should return an empty string - if original array consists of an empty string`, () => { + expect(Array.isArray(result)).toBe(true); + }); + + it(`should reverse a single word`, () => { + expect(arrayReverse(['Hello'])).toEqual(['olleH']); + }); + + it(`should reverse multiple words preserving their original lengths`, () => { expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); }); - // write more tests here + it(`should handle a sentence with single letters and punctuation`, () => { + expect(arrayReverse(['I', 'am', 'a', 'student!'])).toEqual([ + '!', + 'tn', + 'e', + 'dutsamaI', + ]); + }); + + it(`should return an empty array if the original array is empty`, () => { + expect(arrayReverse([])).toEqual([]); + }); + + it(`should handle an array that consists of an empty string`, () => { + expect(arrayReverse([''])).toEqual(['']); + }); + + it(`should correctly handle a mix of empty and non-empty strings`, () => { + expect(arrayReverse(['a', '', 'bc', ''])).toEqual(['c', '', 'ba', '']); + }); + + it(`should mutate the original array (in-place modification)`, () => { + const original = ['abc', 'def']; + const result = arrayReverse(original); + + expect(result).toBe(original); + }); }); From f9b21bd11337b2a502d089dd593b5b0a82f3c0be Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Fri, 10 Jul 2026 09:34:17 +0300 Subject: [PATCH 2/2] removed redundunt tests --- src/arrayReverse.test.js | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index 1835a60..177a92e 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -7,14 +7,8 @@ describe(`Function 'arrayReverse':`, () => { expect(arrayReverse).toBeInstanceOf(Function); }); - it(`should return an array`, () => { - const result = arrayReverse(['test']); - - expect(Array.isArray(result)).toBe(true); - }); - it(`should reverse a single word`, () => { - expect(arrayReverse(['Hello'])).toEqual(['olleH']); + expect(arrayReverse(['Hell0'])).toEqual(['0lleH']); }); it(`should reverse multiple words preserving their original lengths`, () => { @@ -29,23 +23,4 @@ describe(`Function 'arrayReverse':`, () => { 'dutsamaI', ]); }); - - it(`should return an empty array if the original array is empty`, () => { - expect(arrayReverse([])).toEqual([]); - }); - - it(`should handle an array that consists of an empty string`, () => { - expect(arrayReverse([''])).toEqual(['']); - }); - - it(`should correctly handle a mix of empty and non-empty strings`, () => { - expect(arrayReverse(['a', '', 'bc', ''])).toEqual(['c', '', 'ba', '']); - }); - - it(`should mutate the original array (in-place modification)`, () => { - const original = ['abc', 'def']; - const result = arrayReverse(original); - - expect(result).toBe(original); - }); });