Repository navigation
Solution #205
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 #205
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 |
|---|---|---|
|
|
@@ -7,12 +7,45 @@ describe(`Function 'arrayReverse':`, () => { | |
| expect(arrayReverse).toBeInstanceOf(Function); | ||
| }); | ||
|
|
||
| it(`should return an array`, () => {}); | ||
| it(`should return an array`, () => { | ||
| const input = ['Hello', 'World']; | ||
|
|
||
| expect(Array.isArray(arrayReverse(input))).toBe(true); | ||
| }); | ||
|
|
||
| it(`should return an empty string | ||
| if original array consists of an empty string`, () => { | ||
| expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); | ||
| expect(arrayReverse([''])).toEqual(['']); | ||
| }); | ||
|
|
||
| test('reverses characters and preserves original length', () => { | ||
|
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. do linii 14 masz it(...), a od tej linii test(...). dzialaja tak samo, ale wybierz jedno i trzymaj sie tego w calym pliku. wtedy nazwy tez beda w jednym stylu (should ... vs reverses ...) |
||
| const input = ['I', 'am', 'a', 'student!']; | ||
|
|
||
| expect(arrayReverse(input)).toEqual(['!', 'tn', 'e', 'dutsamaI']); | ||
| }); | ||
|
|
||
| test(`reverses one string with a digit | ||
| and a special character as well`, () => { | ||
| const input = ['Hell0!']; | ||
|
|
||
| expect(arrayReverse(input)).toEqual(['!0lleH']); | ||
| }); | ||
|
|
||
| // write more tests here | ||
| test('reverses an empty string', () => { | ||
|
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. spoko, ze jest pusty string, ale brakuje pustej tablicy: arrayReverse([]) -> []. dodaj tez przypadek z pustym stringiem miedzy innymi slowami, np ['', 'abc'] -> ['', 'cba']. wtedy wiadomo, ze slowo o dlugosci 0 dalej ma 0 znakow i nie przesuwa reszty liter 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. ten test to kopia testu z linii 16–19, bo oba sprawdzaja [''] -> ['']. zostaw jeden, najlepiej ten z czytelniejsza nazwa |
||
| const input = ['']; | ||
|
|
||
| expect(arrayReverse(input)).toEqual(['']); | ||
| }); | ||
|
|
||
| test('reverses an array with mixed empty and non-empty strings', () => { | ||
| const input = ['koteł', '', 'pieseł']; | ||
|
|
||
| expect(arrayReverse(input)).toEqual(['łesei', '', 'płetok']); | ||
| }); | ||
|
|
||
| test('handles an empty array', () => { | ||
| const input = []; | ||
|
|
||
| expect(arrayReverse(input)).toEqual([]); | ||
| }); | ||
| }); | ||
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.
podmieniles tu ['Mate', 'Academy'] na pusty string i teraz przyklad ze speca w ogole nie jest testowany. przywroc go jako osobny test, np reverses multiple words of different length. to dobry case, bo dlugosci slow sa odwrotne (4 i 7)