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

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

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

it(`should return an array`, () => {
it(`an empty array
`, () => {
expect(arrayReverse([])).toEqual([]);
});

it(`1 word`, () => {
expect(arrayReverse(["Casablanca"])).toEqual(["acnalbasaC"]);
});

it(`2 words`, () => {
expect(arrayReverse(["Mate", "Academy"])).toEqual(["ymed", "acAetaM"]);
});

it(`an empty strings
`, () => {
expect(arrayReverse(["", "", ""])).toEqual(["", "", ""]);
});

it(`an empty string in the beginning
`, () => {
expect(arrayReverse(["", "Academy"])).toEqual(["", "ymedacA"]);
});

it(`an empty string in the end
`, () => {
expect(arrayReverse(["Academy", ""])).toEqual(["ymedacA", ""]);
});

it(`should return an empty string
if original array consists of an empty string`, () => {
expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']);
it(`an empty string in the middle
`, () => {
expect(arrayReverse(["Mate", "", "Academy"])).toEqual([
"ymed",
"",
"acAetaM",
]);
});

// write more tests here
it(`'words' === ['Hell0']`, () => {
expect(arrayReverse(["Hell0"])).toEqual(["0lleH"]);
});

it(`few words`, () => {
expect(arrayReverse(["I", "am", "a", "student!"])).toEqual([
"!",
"tn",
"e",
"dutsamaI",
]);
});
});