UNPKG

pon-shared-pon.universe.frontend.shared.componentlibrary

Version:

shared components for Pon Universe

39 lines (35 loc) 1.36 kB
import ParseSplitString, { splitString, getTextSnippet } from "./pu-filter-parse-split-string"; describe("ParseSplitString.js", () => { it("returns an empty string when no value is given", () => { expect(ParseSplitString("")).toEqual(""); }); describe("splitString", () => { it("returns false if the seperator ($html) is not present in the given string", () => { expect(splitString("test string without seperator")).toBe(""); }); it("returns an array with trimmed and splitted text if the seperator is present in the given string", () => { expect(splitString("one $html two $html three")).toEqual([ "one", "two", "three" ]); }); }); describe("getTextSnippet", () => { it("returns an empty string if no splitArray is given", () => { expect(getTextSnippet(undefined, 3)).toEqual(""); }); it("returns an empty string if the index surpasses the length of the splitArray", () => { expect(getTextSnippet(["1", "2"], 2)).toEqual(""); }); it("returns the item of the splitArray by the given index", () => { expect(getTextSnippet(["1", "2"], 1)).toEqual("2"); }); it("returns the first item of the array in no index is given", () => { expect(getTextSnippet(["1", "2"])).toEqual("1"); }); }); });