Add additional test for sanitizer
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
ee2cf6e7d5
commit
51baee45a3
@ -1,5 +1,7 @@
|
||||
import { getDomainFromEmail } from "../../src/utils/sanitizer.utils";
|
||||
import { removeNonNumeric } from "../../src/utils/sanitizer.utils";
|
||||
import { removeNonAlpha } from "../../src/utils/sanitizer.utils";
|
||||
import { removeNonAlphanumeric } from "../../src/utils/sanitizer.utils";
|
||||
|
||||
describe("Sanitize Email", () => {
|
||||
const inputs = [
|
||||
@ -30,3 +32,27 @@ describe("Remove non-numeric", () => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("Remove non-Alpha", () => {
|
||||
const inputs = ["DROP/*comment*/sampletable", "10; DROP TABLE members /*"];
|
||||
const outputs = ["DROPcommentsampletable", "DROPTABLEmembers"];
|
||||
for (const key in inputs) {
|
||||
const input = inputs[key];
|
||||
const desired = outputs[key];
|
||||
test(`Should return with only letters: ${key}`, () => {
|
||||
expect(removeNonAlpha(input)).toEqual(desired);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe("Remove non-alphanumeric", () => {
|
||||
const inputs = ["DROP/*comment*/sampletable", "10; DROP TABLE members /*", "1F44"];
|
||||
const outputs = ["DROPcommentsampletable", "10DROPTABLEmembers", "1F44"];
|
||||
for (const key in inputs) {
|
||||
const input = inputs[key];
|
||||
const desired = outputs[key];
|
||||
test(`Should return with only alphanumeric: ${key}`, () => {
|
||||
expect(removeNonAlphanumeric(input)).toEqual(desired);
|
||||
})
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user