import { makeSchemaStub } from '~/data/tests/stubs/make-schema-stub'; import { ThemisSchemaAdapter } from './index'; const makeSut = () => { const stubs = { makeObjectSchema: makeSchemaStub<'object'>(), }; const sut = new ThemisSchemaAdapter(stubs.makeObjectSchema); return { sut, stubs }; }; describe('ThemisSchemaAdapter Test', () => { describe('schema', () => { test('should return an object schema', () => { const { sut, stubs } = makeSut(); const makeSchemaSpy = jest.spyOn(stubs.makeObjectSchema, 'make'); makeSchemaSpy.mockReturnValueOnce('object-schema' as any); const schema = sut.schema({}); expect(schema).toBe('object-schema'); }); test('should create object schema with proper rules', () => { const { sut, stubs } = makeSut(); const makeSchemaSpy = jest.spyOn(stubs.makeObjectSchema, 'make'); sut.schema({ batata: { rules: {}, }, }); expect(makeSchemaSpy).toHaveBeenCalledWith({ required: true, shape: { batata: { rules: {}, }, }, }); }); }); });