Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/arrayReverse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,30 @@ describe(`Function 'arrayReverse':`, () => {
});

it(`should return an array`, () => {
expect(arrayReverse([])).toBeInstanceOf(Array);
expect(arrayReverse(['hello'])).toBeInstanceOf(Array);
});

it(`should correctly reverse a single-element array`, () => {
expect(arrayReverse(['Hello'])).toEqual(['olleH']);
});

it(`should correctly reverse and redistribute characters
for ['I', 'am', 'a', 'student!']`, () => {
expect(arrayReverse(['I', 'am', 'a', 'student!']))
.toEqual(['!', 'tn', 'e', 'dutsamaI']);
});

it(`should return an empty string
if original array consists of an empty string`, () => {
expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']);
it(`should return an empty array for an empty input array`, () => {
expect(arrayReverse([])).toEqual([]);
});

// write more tests here
it(`should handle arrays containing empty strings`, () => {
expect(arrayReverse(['a', '', 'b'])).toEqual(['b', '', 'a']);
expect(arrayReverse(['', 'abc', ''])).toEqual(['', 'cba', '']);
});

it(`should handle strings with special characters and numbers`, () => {
expect(arrayReverse(['@1', 'test', '3$'])).toEqual(['$3', 'tset', '1@']);
});
});