Implemented comprehensive Romanian Biblical Guide web app: - Next.js 15 with App Router and TypeScript - Material UI 7.3.2 for modern, responsive design - PostgreSQL database with Prisma ORM - Complete Bible reader with book/chapter navigation - AI-powered biblical chat with Romanian responses - Prayer wall for community prayer requests - Advanced Bible search with filters and highlighting - Sample Bible data imported from API.Bible - All API endpoints created and working - Professional Material UI components throughout - Responsive layout with navigation and theme 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
137 lines
3.3 KiB
TypeScript
137 lines
3.3 KiB
TypeScript
import {
|
|
userRegistrationSchema,
|
|
userLoginSchema,
|
|
chatMessageSchema,
|
|
prayerRequestSchema,
|
|
bookmarkSchema,
|
|
searchSchema,
|
|
chapterSchema
|
|
} from '@/lib/validation'
|
|
|
|
describe('Validation Schemas', () => {
|
|
describe('userRegistrationSchema', () => {
|
|
it('should validate correct user registration data', () => {
|
|
const validData = {
|
|
email: 'test@example.com',
|
|
password: 'Password123',
|
|
name: 'Test User'
|
|
}
|
|
|
|
const result = userRegistrationSchema.safeParse(validData)
|
|
expect(result.success).toBe(true)
|
|
})
|
|
|
|
it('should reject invalid email', () => {
|
|
const invalidData = {
|
|
email: 'invalid-email',
|
|
password: 'Password123',
|
|
name: 'Test User'
|
|
}
|
|
|
|
const result = userRegistrationSchema.safeParse(invalidData)
|
|
expect(result.success).toBe(false)
|
|
})
|
|
|
|
it('should reject weak password', () => {
|
|
const invalidData = {
|
|
email: 'test@example.com',
|
|
password: 'weak',
|
|
name: 'Test User'
|
|
}
|
|
|
|
const result = userRegistrationSchema.safeParse(invalidData)
|
|
expect(result.success).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('chatMessageSchema', () => {
|
|
it('should validate correct chat message data', () => {
|
|
const validData = {
|
|
messages: [
|
|
{ role: 'user', content: 'Hello' },
|
|
{ role: 'assistant', content: 'Hi there!' }
|
|
]
|
|
}
|
|
|
|
const result = chatMessageSchema.safeParse(validData)
|
|
expect(result.success).toBe(true)
|
|
})
|
|
|
|
it('should reject empty messages array', () => {
|
|
const invalidData = {
|
|
messages: []
|
|
}
|
|
|
|
const result = chatMessageSchema.safeParse(invalidData)
|
|
expect(result.success).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('prayerRequestSchema', () => {
|
|
it('should validate correct prayer request', () => {
|
|
const validData = {
|
|
content: 'Please pray for my family during this difficult time.',
|
|
isAnonymous: true
|
|
}
|
|
|
|
const result = prayerRequestSchema.safeParse(validData)
|
|
expect(result.success).toBe(true)
|
|
})
|
|
|
|
it('should reject too short prayer request', () => {
|
|
const invalidData = {
|
|
content: 'Short',
|
|
isAnonymous: true
|
|
}
|
|
|
|
const result = prayerRequestSchema.safeParse(invalidData)
|
|
expect(result.success).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('searchSchema', () => {
|
|
it('should validate correct search parameters', () => {
|
|
const validData = {
|
|
q: 'love',
|
|
limit: 10
|
|
}
|
|
|
|
const result = searchSchema.safeParse(validData)
|
|
expect(result.success).toBe(true)
|
|
})
|
|
|
|
it('should apply default limit', () => {
|
|
const validData = {
|
|
q: 'love'
|
|
}
|
|
|
|
const result = searchSchema.safeParse(validData)
|
|
expect(result.success).toBe(true)
|
|
if (result.success) {
|
|
expect(result.data.limit).toBe(10)
|
|
}
|
|
})
|
|
})
|
|
|
|
describe('chapterSchema', () => {
|
|
it('should validate correct chapter parameters', () => {
|
|
const validData = {
|
|
book: 1,
|
|
chapter: 1
|
|
}
|
|
|
|
const result = chapterSchema.safeParse(validData)
|
|
expect(result.success).toBe(true)
|
|
})
|
|
|
|
it('should reject invalid book ID', () => {
|
|
const invalidData = {
|
|
book: 0,
|
|
chapter: 1
|
|
}
|
|
|
|
const result = chapterSchema.safeParse(invalidData)
|
|
expect(result.success).toBe(false)
|
|
})
|
|
})
|
|
}) |