AbdulElahGwaith's picture
Upload folder using huggingface_hub
88df9e4 verified
import { describe, test } from 'vitest'
import { validateJson } from '@/tests/lib/validate-json-schema'
import { formatErrors } from '../lib/middleware-errors'
import { schemas } from '../lib/schema'
describe('formatErrors', () => {
test('should produce objects that match the validation spec', () => {
// Produce an error
const { errors } = validateJson({ type: 'string' }, 0)
const formattedErrors = formatErrors(errors || [], '')
for (const formatted of formattedErrors) {
const { isValid, errors: validationErrors } = validateJson(schemas.validation, formatted)
if (!isValid) {
throw new Error(validationErrors?.map((e) => e.message).join(' -- '))
}
}
})
})