feat: add jest and initial tests for masking values
This commit is contained in:
committed by
Christel Westerberg
parent
d84efcbb0f
commit
d28cbf10c7
@@ -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************")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user