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
19 changes: 17 additions & 2 deletions src/arrayReverse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,28 @@ 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([''])).toEqual(['']);

Choose a reason for hiding this comment

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

Optional improvement: add a test that includes an empty string among other elements to cover mixed cases, for example:

expect(arrayReverse(['', 'abc'])).toEqual(['cba', '']);

Consider adding this after the existing empty-string test to improve edge-case coverage.

});

it('should reverses a single word', () => {

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(['Hell0'])).toEqual(['0lleH']);
});

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

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.

});

// write more tests here
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']);
});
});