-
Notifications
You must be signed in to change notification settings - Fork 195
Solution #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Solution #160
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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']); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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']); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
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.