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
39 changes: 36 additions & 3 deletions src/arrayReverse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(['']);

Copy link
Copy Markdown

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)

});

test('reverses characters and preserves original length', () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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', () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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([]);
});
});
Loading