Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

677 B
Raw Blame
import { describe, expect, test } from "vitest";

import { getInitials, nameList } from "./string";

describe("nameList", () => {
  test.each([
    [["a"], "a"],
    [["a", "b"], "a and b"],
    [["a", "b", "c"], "a, b and c"],
    [["a", "b", "c", "d", "e"], "a, b, c and 2 more"]
  ])("%j", (names, expected) => {
    expect(nameList(names)).toBe(expected);
  });
});

describe("getInitials", () => {
  test.each([
    ["Jane Doe", "JD"],
    ["Mary Jane Watson", "MJ"],
    ["[email protected]", "JD"],
    ["[email protected]", "U"],
    ["support-triage", "ST"],
    ["", "?"]
  ])("%j", (value, expected) => {
    expect(getInitials(value)).toBe(expected);
  });
});