Skip to content
Open
Changes from 1 commit
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
23 changes: 21 additions & 2 deletions src/arrayReverse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,32 @@ describe(`Function 'arrayReverse':`, () => {
});

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

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

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

// write more tests here
it('should reverses a single word', () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The test title says it should check the empty-string case, but the assertion checks ['Mate', 'Academy']. Either change the test body to expect(arrayReverse([''])).toEqual(['']) or update the test title and description to match the current assertion.

expect(arrayReverse(['Hello'])).toEqual(['olleH']);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task description requires the example arrayReverse(['Hell0']) === ['0lleH']. Add a test for this exact case (you currently have a single-word test for ['Hello'], but the required example is missing).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task description requires the exact example arrayReverse(['Hell0']) === ['0lleH']. Add a dedicated test such as:

expect(arrayReverse(['Hell0'])).toEqual(['0lleH']);

Place it near the other single-word tests so the required example is explicitly verified (see description) .

});

it('should reverses two words and preserves their lengths', () => {
expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The ['Mate', 'Academy'] example is asserted earlier (mismatched test) and again here, causing duplication. Keep a single clearly-named test for this example and remove the redundant one to avoid overlap.

});

it('should correctly transforms words of different lengths', () => {
expect(arrayReverse(['I', 'am', 'a', 'student!']))
.toEqual(['!', 'tn', 'e', 'dutsamaI']);
});

it('should works with digits and special characters', () => {
expect(arrayReverse(['12$', '#A!'])).toEqual(['!A#', '$21']);
});

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