Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisa18289 committed Jan 16, 2024
1 parent 8b5bc84 commit 8200ad1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ describe('"getInitialsFromString()', () => {
expect(getInitialsFromString("")).toStrictEqual([]);
});

test("does return first character of the first two words", () => {
expect(getInitialsFromString("foo bar baz")).toStrictEqual(["F", "B"]);
});

test("does skip special characters", () => {
expect(getInitialsFromString("foo & bar")).toStrictEqual(["F", "B"]);
});

test("does return one character if only one word is given", () => {
expect(getInitialsFromString("foo")).toStrictEqual(["F"]);
test.each([
["Max Mustermann", "MM"],
["Max & (Mustermann)", "MM"],
["Max", "M"],
])("builds correct initials for %o", (item, expectedResult) => {
expect(getInitialsFromString(item).join("")).toBe(expectedResult);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ describe('"getVariantFromInitials()', () => {
expect(getVariantFromInitials([])).toStrictEqual(1);
});

test.each([[["A"]], [["B"]], [["C", "D"]], [["Z"]], [["Ä"]], [["1"]]])(
"does return number between 1 and 4 for any given initial",
(item) => {
expect(getVariantFromInitials(item)).toBeGreaterThan(0);
expect(getVariantFromInitials(item)).toBeLessThanOrEqual(4);
},
);
test.each([
[["A"], 2],
[["B"], 3],
[["C", "D"], 4],
[["Z"], 3],
[["Ä"], 1],
[["1"], 2],
])("does get correct variant for given initial", (item, expectedVariant) => {
expect(getVariantFromInitials(item)).toBe(expectedVariant);
});
});

0 comments on commit 8200ad1

Please sign in to comment.