Skip to content

Commit 147a2f5

Browse files
committed
feat: code cleanup and test's refactor
1 parent c78e7e4 commit 147a2f5

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

.DS_Store

0 Bytes
Binary file not shown.

__tests__/parseMarkdownToReactEmailJSX.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ console.log(\`Hello, \$\{name\}!\`);
6363
<li>Unordered List Item 2</li>
6464
<li>Unordered List Item 3</li>
6565
</ul>
66-
<h2 style=\"font-weight:500;padding-top:20px;font-size:2rem\">Links</h2><p><a style=\"color:#007bff;text-decoration:underline;background-color:transparent\" href=\"https://www.markdownguide.org\" target=\"_blank\">Markdown Guide</a></p>
67-
<h2 style=\"font-weight:500;padding-top:20px;font-size:2rem\">Images</h2><p><img alt=\"Markdown Logo\" src=\"https://markdown-here.com/img/icon256.png\"></p>
66+
<h2 style=\"font-weight:500;padding-top:20px;font-size:2rem\">Links</h2><p><a href=\"https://www.markdownguide.org\" target=\"_blank\" style=\"color:#007bff;text-decoration:underline;background-color:transparent\">Markdown Guide</a></p>
67+
<h2 style=\"font-weight:500;padding-top:20px;font-size:2rem\">Images</h2><p><img src=\"https://markdown-here.com/img/icon256.png\" alt=\"Markdown Logo\"></p>
6868
<h2 style=\"font-weight:500;padding-top:20px;font-size:2rem\">Blockquotes</h2><blockquote style=\"background:#f9f9f9;border-left:10px solid #ccc;margin:1.5em 10px;padding:1em 10px\">
6969
<p>This is a blockquote.</p>
7070
<ul>
@@ -232,12 +232,12 @@ greet("World")
232232

233233
it("handles blockquotes correctly", () => {
234234
const markdown = `A example:
235-
> Here's a block quote:
235+
> Here\'s a block quote:
236236
> Lorem ipsum dolor sit amet, consectetur adipiscing elit.`;
237237

238238
const expected = `<p>A example:</p>
239239
<blockquote style="background:#f9f9f9;border-left:10px solid #ccc;margin:1.5em 10px;padding:1em 10px">
240-
<p>Here's a block quote:
240+
<p>Here&#39;s a block quote:
241241
Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
242242
</blockquote>
243243
`;
@@ -264,10 +264,10 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
264264

265265
it("handles links correctly", () => {
266266
const markdown = `A link example:
267-
Here's a link to [OpenAI's website](https://openai.com/).`;
267+
Here's a link to [OpenAI\'s website](https://openai.com/).`;
268268

269269
const expected = `<p>A link example:
270-
Here's a link to <a style="color:#007bff;text-decoration:underline;background-color:transparent" href="https://openai.com/" target="_blank">OpenAI's website</a>.</p>
270+
Here&#39;s a link to <a href="https://openai.com/" target="_blank" style="color:#007bff;text-decoration:underline;background-color:transparent">OpenAI&#39;s website</a>.</p>
271271
`;
272272

273273
const rendered = parseMarkdownToReactEmailJSX({

__tests__/reactEmailMarkdown.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("ReactEmailMarkdown component renders correctly", () => {
88
<ReactEmailMarkdown markdown={`# Hello, World!`} />
99
);
1010
expect(actualOutput).toMatchInlineSnapshot(
11-
`"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><div><h1 data-id="react-email-heading" style="font-weight:500;padding-top:20px;font-size:2.5rem">Hello, World!</h1></div>"`
11+
`"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><div><h1 style="font-weight:500;padding-top:20px;font-size:2.5rem" data-id="react-email-heading">Hello, World!</h1></div>"`
1212
);
1313
});
1414
});

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const initRenderer = ({
154154
parseCssInJsToInlineCss(finalStyles.image) !== ""
155155
? ` style="${parseCssInJsToInlineCss(finalStyles.image)}"`
156156
: ""
157-
} />`;
157+
}>`;
158158
return out;
159159
},
160160

@@ -179,7 +179,7 @@ export const initRenderer = ({
179179
"<" +
180180
type +
181181
startatt +
182-
`${styles !== "" ? ` style="${styles}"` : ""} >\n` +
182+
`${styles !== "" ? ` style="${styles}"` : ""}>\n` +
183183
body +
184184
"</" +
185185
type +

0 commit comments

Comments
 (0)