import { describe, expect, test } from "@jest/globals"

import { all, email, phone, text } from "./maskValue"

describe("Mask value", () => {
  test("masks e-mails properly", () => {
    expect(email("test@example.com")).toBe("t***@e******.com")
    expect(email("test@sub.example.com")).toBe("t***@s**.e******.com")
    expect(email("test_no_atexample.com")).toBe("t********************")
    expect(email("test_no_dot@examplecom")).toBe("t*********************")
    expect(email("test_no_at_no_dot_com")).toBe("t********************")
  })

  test("masks phone number properly", () => {
    expect(phone("0000000000")).toBe("********00")
  })

  test("masks text strings properly", () => {
    expect(text("test")).toBe("t***")
    expect(text("test.with.dot")).toBe("t************")
  })

  test("masks whole string properly", () => {
    expect(all("test")).toBe("****")
    expect(all("123jknasd@iajsd.c")).toBe("*****************")
  })
})
