import { IAnySchemaRules } from '~/domain/entities/schemas/any-schema'; import { expectResult, getMakeSut } from './helpers'; describe('Integration - Object Tests - Required', () => { const makeSut = getMakeSut('object'); const req = (value: boolean): IAnySchemaRules => ({ required: value }); describe('[required = true], should throw error if value is falsy', () => { const { sut } = makeSut(req(true)); test(`should not allow null`, () => { expectResult(sut.validate(null)).toBeInvalid(); }); test(`should not allow undefined`, () => { expectResult(sut.validate(undefined)).toBeInvalid(); }); }); describe('[required = false], should not throw error if value is falsy', () => { const { sut } = makeSut(req(false)); test(`should not allow null`, () => { expectResult(sut.validate(null)).toBeValid(); }); test(`should not allow undefined`, () => { expectResult(sut.validate(undefined)).toBeValid(); }); }); });