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
47 changes: 43 additions & 4 deletions src/arrayReverse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,53 @@ describe(`Function 'arrayReverse':`, () => {
expect(arrayReverse).toBeInstanceOf(Function);
});

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

it(`1 word`, () => {
expect(arrayReverse(['Casablanca'])).toEqual(['acnalbasaC']);
});

Choose a reason for hiding this comment

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

You've done a good job testing arrays that contain empty strings. It would be beneficial to also add a test case for when the input array itself is empty, like arrayReverse([]). According to the function's logic, this should result in an empty array.

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

// write more tests here
it(`an empty strings
`, () => {
expect(arrayReverse(['', '', ''])).toEqual(['', '', '']);
});

it(`an empty string in the beginning
`, () => {
expect(arrayReverse(['', 'Academy'])).toEqual(['', 'ymedacA']);
});

it(`an empty string in the end
`, () => {
expect(arrayReverse(['Academy', ''])).toEqual(['ymedacA', '']);
});

it(`an empty string in the middle
`, () => {
expect(arrayReverse(['Mate', '', 'Academy'])).toEqual([
'ymed',
'',
'acAetaM',
]);
});

it(`'words' === ['Hell0']`, () => {
expect(arrayReverse(['Hell0'])).toEqual(['0lleH']);
});

it(`few words`, () => {
expect(arrayReverse(['I', 'am', 'a', 'student!'])).toEqual([
'!',
'tn',
'e',
'dutsamaI',
]);
});
});