import { IsThemisSchemaAdapter } from '~/data/helpers/is-themis-schema/load'; import { schemaFactory } from '~/data/tests/factories/schema'; import { ValidationSchemas } from '~/domain'; const makeSut = () => { const sut = new IsThemisSchemaAdapter(false); return { sut }; }; describe('isThemisSchema test', () => { test('should return true on schema object', () => { const { sut } = makeSut(); expect(sut.isSchema(schemaFactory.make({}))).toBe(true); }); test('should return false on non-schema object', () => { const { sut } = makeSut(); expect(sut.isSchema({})).toBe(false); expect(sut.isSchema([])).toBe(false); }); test('should return false on objects that are similar to schema, but are not schema', () => { const { sut } = makeSut(); const schema: ValidationSchemas = { type: 'string', rules: {}, validate: jest.fn(), }; expect(sut.isSchema(schema)).toBe(false); }); test('should return false on non object', () => { const { sut } = makeSut(); const values = ['schema', 10, 0, null, undefined, true, Symbol('batata')]; values.forEach(value => expect(sut.isSchema(value)).toBe(false)); }); });