ce76046a29
- consolidate API ownership and remove dead vendor code - add Stripe billing, learning paths, and public CV hardening - add migration, recovery, security, audit, and browser gates
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import '@testing-library/jest-dom';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
|
|
|
import { api } from './api';
|
|
import PublicCvPage from './views/PublicCvPage';
|
|
|
|
jest.mock('./api', () => ({
|
|
api: {
|
|
defaults: { baseURL: '/api' },
|
|
get: jest.fn(),
|
|
},
|
|
}));
|
|
|
|
const mockedApi = api as jest.Mocked<typeof api>;
|
|
|
|
test('public CV exposes the rendered CV and PDF download', async () => {
|
|
mockedApi.get.mockResolvedValueOnce({ data: { html: '<p>Public CV</p>', name: 'Ada Lovelace' } } as any);
|
|
|
|
render(
|
|
<MemoryRouter initialEntries={['/cv/public-slug']} future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
|
|
<Routes><Route path="/cv/:slug" element={<PublicCvPage />} /></Routes>
|
|
</MemoryRouter>,
|
|
);
|
|
|
|
expect(await screen.findByTitle('Public CV')).toHaveAttribute('srcdoc', '<p>Public CV</p>');
|
|
expect(screen.getByRole('link', { name: 'Download PDF' })).toHaveAttribute('href', '/api/public-cv/public-slug/pdf');
|
|
expect(mockedApi.get).toHaveBeenCalledWith('/public-cv/public-slug');
|
|
});
|