feat: add jest and initial tests for masking values

This commit is contained in:
Michael Zetterberg
2024-06-19 09:30:06 +02:00
committed by Christel Westerberg
parent d84efcbb0f
commit d28cbf10c7
9 changed files with 3462 additions and 62 deletions
+22
View File
@@ -0,0 +1,22 @@
import { describe, expect, test } from "@jest/globals"
import { 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************")
})
})