File size: 1,029 Bytes
dce7eca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { render, screen, fireEvent } from '@testing-library/react'
import UploadSection from '@/components/UploadSection'

describe('UploadSection', () => {
    const mockOnGenerate = jest.fn()

    beforeEach(() => {
        jest.clearAllMocks()
    })

    it('renders upload area and input', () => {
        render(<UploadSection onGenerate={mockOnGenerate} isGenerating={false} />)
        expect(screen.getByText('Upload Reference Photos')).toBeInTheDocument()
        expect(screen.getByPlaceholderText(/A modern living room/)).toBeInTheDocument()
    })

    it('calls onGenerate when button clicked', () => {
        render(<UploadSection onGenerate={mockOnGenerate} isGenerating={false} />)
        const textarea = screen.getByPlaceholderText(/A modern living room/)
        fireEvent.change(textarea, { target: { value: 'Beautiful sunset' } })

        const button = screen.getByText(/Create 360/)
        fireEvent.click(button)

        expect(mockOnGenerate).toHaveBeenCalledWith('Beautiful sunset', [])
    })
})