Corrections to unit tests

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface
2023-08-01 22:45:08 +01:00
parent 0e748d545e
commit 2d2fdbb8db
8 changed files with 97 additions and 66 deletions

View File

@@ -0,0 +1,9 @@
import { removeNewlineAndPTag } from "../../src/utils/newSanitizer";
describe('newSanitizer', () => {
test('Should remove /\n and <p>/</p> elements', () => {
const input = "\n<p>This is a string</p>";
const expectedOutput = "This is a string"
expect(removeNewlineAndPTag(input)).toEqual(expectedOutput);
});
});

View File

@@ -1,9 +1,18 @@
import { removeNewlineAndPTag } from "../../src/utils/sanitizer.utils";
import { getDomainFromEmail } from "../../src/utils/sanitizer.utils";
describe('sanitizer', () => {
test('Should remove /\n and <p>/</p> elements', () => {
const input = "\n<p>This is a string</p>";
const expectedOutput = "This is a string"
expect(removeNewlineAndPTag(input)).toEqual(expectedOutput);
});
});
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);
})
}
});

View File

@@ -19,7 +19,7 @@ export const inputs: any[] = [
{
rid: "202308017159276",
uid: "G59276",
trainuid: "1M83",
trainid: "1M83",
sdd: "2023-08-01",
operator: "CrossCountry",
operatorCode: "XC",

View File

@@ -35,6 +35,8 @@ export const outputs: any[] = [
}
]
}
]
],
busServices: [],
ferryServices: []
},
]