import { schemaTypes } from '~/domain'; import { ValidationBuilder } from '~/domain/protocols'; import { IThemisMethods } from '~/domain/themis/themis-methods'; import { IThemisAdapter } from '~/presentation/use-cases/themis'; const makeStubs = () => { const builder: ValidationBuilder = { number: jest.fn(), string: jest.fn(), object: jest.fn(), array: jest.fn(), custom: {} as any, }; const methods: IThemisMethods = { schema: jest.fn(), }; return { builder, methods }; }; const makeSut = () => { const stubs = makeStubs(); const sut = new IThemisAdapter(stubs.builder, stubs.methods); return { sut, stubs }; }; describe('ThemisAdapter Test', () => { schemaTypes.forEach(type => { test(`themis.${type} should be properly set`, () => { const { sut, stubs } = makeSut(); expect(sut[type]).toBeDefined(); expect(sut[type]).toBe(stubs.builder[type]); }); }); test(`themis.schema should be properly set`, () => { const { sut, stubs } = makeSut(); expect(sut.schema).toBeDefined(); expect(sut.schema).toBe(stubs.methods.schema); }); });