1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 19:59:27 +00:00

Refactored sanitisation function to allow more expandability and removed the need to clone the body

This commit is contained in:
2022-02-19 21:11:16 +00:00
parent e1ae4f8b5f
commit bcdc79e897
2 changed files with 40 additions and 11 deletions

View File

@@ -118,6 +118,24 @@ describe('validate', () => {
}).toThrow('missing');
});
test('Unrequired fields added to map', () => {
const body = {
name: 'Bob',
message: 'Hi Jim! '
};
const fields = [
'name',
];
const result = validator.validate(body, fields);
expect(result).toBeObject();
expect(result).toContainKey('fields');
expect(result.fields.get('name')).toBe('Bob');
expect(result.fields.get('message')).toBe('Hi Jim!');
});
test('Valid email validation', () => {
const body = {
name: 'Bob',