6995-testToMaster_2410 #2139

Merged
alexm merged 236 commits from 6995-testToMaster_2410 into master 2024-03-07 07:09:08 +00:00
1 changed files with 132 additions and 2 deletions
Showing only changes of commit 3822183095 - Show all commits

View File

@ -1,5 +1,136 @@
/* eslint-disable jasmine/no-spec-dupes */
const validatorBodyModel = require('../body_model_validator');
fdescribe('Validation Model', () => {
describe('should be number', () => {
it('success', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'number'
}], {property: 1});
expect(isValid).toBeTrue();
});
it('fail', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'number'
}], {property: null});
expect(isValid).toBeFalse();
});
});
describe('should be string', () => {
it('success as number', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'string'
}], {property: '1234'});
expect(isValid).toBeTrue();
});
it('success as string', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'string'
}], {property: 'null'});
expect(isValid).toBeTrue();
});
it('fail', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'string'
}], {property: null});
expect(isValid).toBeFalse();
});
});
describe('should be date', () => {
it('success', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'date'
}], {property: new Date()});
expect(isValid).toBeTrue();
});
it('fail', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'date'
}], {property: null});
expect(isValid).toBeFalse();
});
});
describe('should be boolean', () => {
it('success as true', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'boolean'
}], {property: true});
expect(isValid).toBeTrue();
});
it('success as false', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'boolean'
}], {property: false});
expect(isValid).toBeTrue();
});
it('fail', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'boolean'
}], {property: null});
expect(isValid).toBeFalse();
});
});
describe('should be any', () => {
it('success', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'any'
}], {property: '1234'});
expect(isValid).toBeTrue();
});
it('fail', () => {
let {isValid} = validatorBodyModel([{
arg: 'property',
type: 'any'
}], {property: null});
expect(isValid).toBeFalse();
});
});
});
describe('Validation Client Create', () => {
const newAccount = {
userName: 'Deadpool',
@ -120,7 +251,6 @@ describe('Validation Client Create', () => {
it('should not be able to create a user if exists', async() => {
let isValid = false;
let error;
isValid = validatorBodyModel(CLIENT_MODEL, newAccount).isValid;