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:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user