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
40 changes: 34 additions & 6 deletions src/arrayReverse.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
'use strict';

describe(`Function 'arrayReverse':`, () => {
describe("Function 'arrayReverse':", () => {
const arrayReverse = require('./arrayReverse');

it(`should be declared`, () => {
it('should be declared', () => {
expect(arrayReverse).toBeInstanceOf(Function);
});

it(`should return an array`, () => {
it('should return an array', () => {
const result = arrayReverse(['abc']);

expect(Array.isArray(result)).toBe(true);
});

it(`should return an empty string
if original array consists of an empty string`, () => {
it('should reverse a single word', () => {
expect(arrayReverse(['Hell0'])).toEqual(['0lleH']);
});

it('should reverse multiple words keeping 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.

Issue: The expected output ['ymed', 'acAetaM'] does not match the logic of reversing each word individually. For input ['Mate', 'Academy'], the expected output should be ['etaM', 'ymedacA'] if each word is reversed separately. Please verify the requirements and adjust the expected output accordingly.

Choose a reason for hiding this comment

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

Issue: The expected output in this test case does not match the requirement of reversing each word individually. For input ['Mate', 'Academy'], the expected output should be ['etaM', 'ymedacA'], not ['ymed', 'acAetaM']. Please update the expected output to reflect the correct logic as described in the task requirements.

});

// write more tests here
it('should handle an array of multiple small words', () => {
expect(arrayReverse(['I', 'am', 'a', 'student!'])).toEqual([
'!',
'tn',
'e',
'dutsamaI',
]);
});

it('should return arr with empty str if arr consists empty string', () => {
expect(arrayReverse([''])).toEqual(['']);
});

it('should handle empty array', () => {
expect(arrayReverse([])).toEqual([]);
});

it('should handle array with multiple empty strings', () => {
expect(arrayReverse(['', '', ''])).toEqual(['', '', '']);
});

it('should correctly reverse str with special chars and digits', () => {
expect(arrayReverse(['12$', '%^&'])).toEqual(['&^%', '$21']);
});
});