Spaces:
Running
Running
| import { describe, it, expect, vi } from 'vitest'; | |
| import { render } from '@testing-library/react'; | |
| import Viewer3D from './Viewer3D'; | |
| vi.mock('@react-three/fiber', () => ({ | |
| Canvas: ({ children }: any) => <div>{children}</div>, | |
| useFrame: () => {}, | |
| useLoader: () => ({}), | |
| })); | |
| vi.mock('@react-three/drei', () => ({ | |
| OrbitControls: () => null, | |
| Environment: () => null, | |
| PerspectiveCamera: () => null, | |
| Html: ({ children }: any) => <div>{children}</div>, | |
| ContactShadows: () => null, | |
| useGLTF: () => ({ scene: null, animations: [] }), | |
| useAnimations: () => ({ actions: {}, mixer: null, names: [] }), | |
| })); | |
| describe('Viewer3D', () => { | |
| it('renders without crashing when modelUrl is null', () => { | |
| const { container } = render(<Viewer3D modelUrl={null} />); | |
| expect(container).toBeTruthy(); | |
| }); | |
| it('renders without crashing when modelUrl is provided', () => { | |
| const { container } = render(<Viewer3D modelUrl="http://localhost:8000/output/abc/model.glb" />); | |
| expect(container).toBeTruthy(); | |
| }); | |
| }); | |