PR feedback + remove redundant code + add a test

This commit is contained in:
Jens Neuber
2022-01-04 16:00:21 +01:00
parent f455e3a454
commit 6acc9546a0
4 changed files with 58 additions and 28 deletions

View File

@@ -164,3 +164,25 @@ describe("Test reset-password", () => {
}, 120000);
});
describe("The function filterAndJoin", () => {
it("should join and array of strings to one string", () => {
const result = utilServerRewire.filterAndJoin(["one", "two", "three"]);
expect(result).toBe("onetwothree");
});
it("should join strings using a given connector", () => {
const result = utilServerRewire.filterAndJoin(["one", "two", "three"], "-");
expect(result).toBe("one-two-three");
});
it("should filter null, undefined and empty strings before joining", () => {
const result = utilServerRewire.filterAndJoin([undefined, "", "three"], "--");
expect(result).toBe("three");
});
it("should return an empty string if all parts are filtered out", () => {
const result = utilServerRewire.filterAndJoin([undefined, "", ""], "--");
expect(result).toBe("");
});
});