import { describe, expect, it } from "bun:test";

import { mask } from "./mask";

describe("mask", () => {
    it("should return empty string for empty input", () => {
        expect(mask("")).toBe("");
    });

    it("should mask string with default parameters", () => {
        expect(mask("1234567890")).toBe("12******90");
    });

    it("should show custom number of characters at start", () => {
        expect(mask("1234567890", { visibleStart: 3 })).toBe("123*****90");
    });

    it("should show custom number of characters at end", () => {
        expect(mask("1234567890", { visibleStart: 2, visibleEnd: 3 })).toBe(
            "12*****890",
        );
    });

    it("should mask entire string when visible parts exceed length", () => {
        expect(mask("123", { visibleStart: 2, visibleEnd: 2 })).toBe("***");
    });

    it("should handle undefined end part", () => {
        expect(mask("1234567890", { visibleStart: 2, visibleEnd: 0 })).toBe(
            "12********",
        );
    });

    it("should handle long strings", () => {
        expect(mask("12345678901234567890")).toBe("12**********90");
    });

    it("should handle emails", () => {
        expect(mask("test.testsson@scandichotels.com")).toBe(
            "te*********on@sc*********ls.com",
        );
    });
});
