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
26 changes: 24 additions & 2 deletions src/arrayReverse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,35 @@ describe(`Function 'arrayReverse':`, () => {
});

it(`should return an array`, () => {

expect(arrayReverse(['Hello'])).toBeInstanceOf(Array);
});

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

// write more tests here
it(`should return an array with a reversed string
if original array has only one sentence`, () => {
expect(arrayReverse(['Hell0'])).toEqual(['0lleH']);
});

it(`should return an array with reverses
and keep original array string lengths
if original array has two or more sentences`, () => {
expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']);
});

it(`should return an array with reverses
and keep original array string lengths
if original array has two or more sentences
(including numbers and punctuation)`, () => {
expect(arrayReverse(['I', 'am', 'a', 'student!']))
.toEqual(['!', 'tn', 'e', 'dutsamaI']);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests cover all the examples from the description very well. To make your test suite even more comprehensive, consider adding a test for an edge case: what should the function return when given an empty array, like arrayReverse([])?


it('should return an empty array if original array is empty', () => {
expect(arrayReverse([])).toEqual([]);
});
});