mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 18:19:25 +00:00
Add tests for validator 'values' type
This commit is contained in:
@@ -282,6 +282,48 @@ describe('validate', () => {
|
|||||||
}).toThrow('Invalid');
|
}).toThrow('Invalid');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Valid values validation', () => {
|
||||||
|
const body = {
|
||||||
|
times: '1'
|
||||||
|
};
|
||||||
|
|
||||||
|
const fields = [
|
||||||
|
'times'
|
||||||
|
];
|
||||||
|
|
||||||
|
const validation = {
|
||||||
|
values: {
|
||||||
|
times: [ '5', '6', '7', '1' ]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = validator.validate(body, fields, validation);
|
||||||
|
|
||||||
|
expect(result).toBeObject();
|
||||||
|
expect(result).toContainKey('fields');
|
||||||
|
expect(result.fields.get('times')).toEqual('1');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Invalid values validation', () => {
|
||||||
|
const body = {
|
||||||
|
times: '1'
|
||||||
|
};
|
||||||
|
|
||||||
|
const fields = [
|
||||||
|
'times'
|
||||||
|
];
|
||||||
|
|
||||||
|
const validation = {
|
||||||
|
values: {
|
||||||
|
times: [ '5', '6', '7' ]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
validator.validate(body, fields, validation);
|
||||||
|
}).toThrow('Invalid');
|
||||||
|
});
|
||||||
|
|
||||||
test('Invalid validation type', () => {
|
test('Invalid validation type', () => {
|
||||||
const body = {
|
const body = {
|
||||||
name: 'Bob',
|
name: 'Bob',
|
||||||
|
|||||||
Reference in New Issue
Block a user