Skip to content

Commit e37aeff

Browse files
authored
Merge pull request #165 from 1chooo/fix/#163
Fix/#163
2 parents c602b70 + 39ac427 commit e37aeff

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

src/components/resume/timeline-item.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
2-
import ReactMarkdown from "react-markdown";
3-
import remarkGfm from "remark-gfm";
2+
import MarkdownRenderer from "@/components/markdown/markdown-renderer";
43

54
import "@/styles/resume/timeline-item.css";
65

@@ -29,11 +28,9 @@ const TimelineItem: React.FC<TimelineItemProps> = ({
2928
<span className="profession-experience-duration">🗓️ {duration}</span>
3029
</p>
3130
<br />
32-
<p className="timeline-text">
33-
<ReactMarkdown remarkPlugins={[remarkGfm]}>
34-
{tasksMarkdown}
35-
</ReactMarkdown>
36-
</p>
31+
<div className="timeline-text">
32+
<MarkdownRenderer content={tasksMarkdown} />
33+
</div>
3734
</li>
3835
);
3936

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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

Comments
 (0)