|
| 1 | +import React from 'react'; |
| 2 | +import { render, screen } from '@testing-library/react'; |
| 3 | +import TimelineItem, { TimelineItemProps } from '@/components/resume/timeline-item'; |
| 4 | +import '@testing-library/jest-dom/extend-expect'; |
| 5 | + |
| 6 | +describe('TimelineItem Component', () => { |
| 7 | + const mockProps: TimelineItemProps = { |
| 8 | + company: 'Test Company', |
| 9 | + location: 'Test Location', |
| 10 | + role: 'Test Role', |
| 11 | + duration: 'Test Duration', |
| 12 | + tasksMarkdown: '- Task 1\n- Task 2\n- Task 3', |
| 13 | + }; |
| 14 | + |
| 15 | + it('should not render <ul> inside a <p> tag', () => { |
| 16 | + const { container } = render(<TimelineItem {...mockProps} />); |
| 17 | + |
| 18 | + // Find the <ul> element inside the rendered component |
| 19 | + const ulElement = container.querySelector('ul'); |
| 20 | + |
| 21 | + // Ensure <ul> is not a descendant of a <p> tag |
| 22 | + const ulParentTag = ulElement?.parentElement?.tagName.toLowerCase(); |
| 23 | + expect(ulParentTag).not.toBe('p'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should render the tasksMarkdown correctly inside a <div>', () => { |
| 27 | + render(<TimelineItem {...mockProps} />); |
| 28 | + |
| 29 | + // Check that the Markdown list is rendered correctly within the div |
| 30 | + const divElement = screen.getByText('Task 1').closest('div'); |
| 31 | + expect(divElement).toBeInTheDocument(); |
| 32 | + }); |
| 33 | +}); |
0 commit comments