32 lines
1019 B
TypeScript
32 lines
1019 B
TypeScript
import { getDomainFromEmail } from "../../src/utils/sanitizer.utils";
|
|
import { removeNonNumeric } from "../../src/utils/sanitizer.utils";
|
|
|
|
describe("Sanitize Email", () => {
|
|
const inputs = [
|
|
"this+is+an-_email@example.com",
|
|
'"unusual email"@example.com',
|
|
"(brackets)addr@example.com",
|
|
"I%Have{Special}%Characters@example.com",
|
|
"Basic.address@example.com",
|
|
`"very.(),:;<>[]\".VERY.\"very\ \"very\".unusual"@example.com`,
|
|
];
|
|
const expectedOutput = "example.com";
|
|
for (const addr of inputs) {
|
|
test(`Should return only domain: ${addr}`, () => {
|
|
expect(getDomainFromEmail(addr)).toEqual(expectedOutput);
|
|
});
|
|
}
|
|
});
|
|
|
|
describe("Remove non-numeric", () => {
|
|
const inputs = ["abc123", "<%43)($£@:}jfkd4"];
|
|
const expectedOutputs = ["123", "434"];
|
|
for (const key in inputs) {
|
|
const input = inputs[key];
|
|
const desired = expectedOutputs[key];
|
|
test(`Should return only numbers: ${key}`, () => {
|
|
expect(removeNonNumeric(input)).toEqual(desired);
|
|
});
|
|
}
|
|
});
|