import { expectResult, getMakeSut, getAnyString } from './helpers'; describe('Integration - String Tests', () => { const makeSut = getMakeSut('string'); const doTest = (value: unknown, valid: boolean) => { const { sut } = makeSut(); expectResult(sut.validate(value)).toBe(valid); }; describe('should allow only strings or null or undefined', () => { const stringCases = getAnyString(); stringCases.forEach(testCase => { test(`should allow [ ${testCase} ]`, () => { doTest(testCase, true); }); }); const nonStringCases = [ [0], [1], ['objeto', { batata: 2 }], ['array', []], ['Set', new Set()], ['Date', new Date()], ]; nonStringCases.forEach(testCase => { const [name, value] = testCase.length === 1 ? [String(testCase), testCase] : testCase; test(`should not allow [ ${name} ]`, () => { doTest(value, false); }); }); }); });