|
| 1 | +import { render, screen } from '@testing-library/react'; |
| 2 | +import '@testing-library/jest-dom/vitest'; |
| 3 | +import { describe, expect, it, vi } from 'vitest'; |
| 4 | + |
| 5 | +vi.mock('./CompareClient', () => ({ |
| 6 | + default: () => <div>Mock Compare Client</div>, |
| 7 | +})); |
| 8 | + |
| 9 | +vi.mock('../components/Footer', () => ({ |
| 10 | + Footer: () => <div>Mock Footer</div>, |
| 11 | +})); |
| 12 | + |
| 13 | +import ComparePage from './page'; |
| 14 | + |
| 15 | +describe('ComparePage mock integrations', () => { |
| 16 | + it('renders CompareClient through mocked service layer', () => { |
| 17 | + render(<ComparePage />); |
| 18 | + |
| 19 | + expect(screen.getByText('Mock Compare Client')).toBeInTheDocument(); |
| 20 | + }); |
| 21 | + |
| 22 | + it('renders Footer component', () => { |
| 23 | + render(<ComparePage />); |
| 24 | + |
| 25 | + expect(screen.getByText('Mock Footer')).toBeInTheDocument(); |
| 26 | + }); |
| 27 | + |
| 28 | + it('renders CompareClient only once', () => { |
| 29 | + render(<ComparePage />); |
| 30 | + |
| 31 | + expect(screen.getAllByText('Mock Compare Client')).toHaveLength(1); |
| 32 | + }); |
| 33 | + |
| 34 | + it('renders Footer only once', () => { |
| 35 | + render(<ComparePage />); |
| 36 | + |
| 37 | + expect(screen.getAllByText('Mock Footer')).toHaveLength(1); |
| 38 | + }); |
| 39 | + |
| 40 | + it('renders page layout with both mocked integrations', () => { |
| 41 | + render(<ComparePage />); |
| 42 | + |
| 43 | + expect(screen.getByText('Mock Compare Client')).toBeInTheDocument(); |
| 44 | + expect(screen.getByText('Mock Footer')).toBeInTheDocument(); |
| 45 | + }); |
| 46 | +}); |
0 commit comments