From 93009da57d35d2a7bc26a5db74fc1667502e2479 Mon Sep 17 00:00:00 2001 From: pparys93 Date: Wed, 11 Nov 2026 19:36:15 +0100 Subject: [PATCH 1/2] Solution --- src/arrayReverse.test.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index 6e7ca36..35fe218 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -14,5 +14,18 @@ describe(`Function 'arrayReverse':`, () => { expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); }); - // write more tests here + test('reserves characters and preserves original length', () => { + const input = ['Mate', 'Academy']; + expect(arrayReverse(input)).toEqual(['ymed', 'acAetaM']); + }); + + test('reverses one string', () => { + const input = ['Hell0']; + expect(arrayReverse(input)).toEqual(['0lleH']); + }); + + test('reverses an empty string', () => { + const input = ['']; + expect(arrayReverse(input)).toEqual(['']); + }); }); From e20628b4523c760833d7db79824c7f5a2ff99ae7 Mon Sep 17 00:00:00 2001 From: pparys93 Date: Thu, 12 Nov 2026 19:12:10 +0100 Subject: [PATCH 2/2] Solution, the second approach --- src/arrayReverse.test.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index 35fe218..6dea300 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -7,25 +7,45 @@ describe(`Function 'arrayReverse':`, () => { expect(arrayReverse).toBeInstanceOf(Function); }); - it(`should return an array`, () => {}); + it(`should return an array`, () => { + const input = ['Hello', 'World']; + + expect(Array.isArray(arrayReverse(input))).toBe(true); + }); it(`should return an empty string if original array consists of an empty string`, () => { - expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); + expect(arrayReverse([''])).toEqual(['']); }); - test('reserves characters and preserves original length', () => { - const input = ['Mate', 'Academy']; - expect(arrayReverse(input)).toEqual(['ymed', 'acAetaM']); + test('reverses characters and preserves original length', () => { + const input = ['I', 'am', 'a', 'student!']; + + expect(arrayReverse(input)).toEqual(['!', 'tn', 'e', 'dutsamaI']); }); - test('reverses one string', () => { - const input = ['Hell0']; - expect(arrayReverse(input)).toEqual(['0lleH']); + test(`reverses one string with a digit + and a special character as well`, () => { + const input = ['Hell0!']; + + expect(arrayReverse(input)).toEqual(['!0lleH']); }); test('reverses an empty string', () => { const input = ['']; + expect(arrayReverse(input)).toEqual(['']); }); + + test('reverses an array with mixed empty and non-empty strings', () => { + const input = ['koteł', '', 'pieseł']; + + expect(arrayReverse(input)).toEqual(['łesei', '', 'płetok']); + }); + + test('handles an empty array', () => { + const input = []; + + expect(arrayReverse(input)).toEqual([]); + }); });