From 27a34eb99243ad40e625ee4d91224863affd0bf8 Mon Sep 17 00:00:00 2001 From: lordelogos Date: Tue, 4 Jul 2023 14:39:41 +0100 Subject: [PATCH] feat: added type checks and handled null type values --- CHANGELOG.md | 7 +++++ .../parseMarkdownToReactEmailJSX.test.ts | 30 +++++++++++++++++++ package.json | 2 +- src/utils.ts | 9 ++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d99a22b..d19a34d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +### [3.0.2](https://github.com/codeskills-dev/md-to-react-email/compare/v3.0.1...v3.0.2) (2023-07-04) + +### Features + +- Added checks to handle `undefined | null | ''` +- Added checks to handle input that is not of type `string` + ### [3.0.1](https://github.com/codeskills-dev/md-to-react-email/compare/v3.0.0...v3.0.1) (2023-07-04) ### Features diff --git a/__tests__/parseMarkdownToReactEmailJSX.test.ts b/__tests__/parseMarkdownToReactEmailJSX.test.ts index 0f5a22e..ac5bd74 100644 --- a/__tests__/parseMarkdownToReactEmailJSX.test.ts +++ b/__tests__/parseMarkdownToReactEmailJSX.test.ts @@ -5,6 +5,36 @@ import { } from "../src"; describe("Markdown to React Mail JSX Parser", () => { + it("handles empty string correctly", () => { + const markdown = ""; + const expected = ``; + + const rendered = parseMarkdownToReactEmailJSX({ + markdown, + }); + expect(rendered).toBe(expected); + }); + + it("handles undefined string correctly", () => { + const markdown = undefined as unknown as string; + const expected = ``; + + const rendered = parseMarkdownToReactEmailJSX({ + markdown, + }); + expect(rendered).toBe(expected); + }); + + it("handles null string correctly", () => { + const markdown = null as unknown as string; + const expected = ``; + + const rendered = parseMarkdownToReactEmailJSX({ + markdown, + }); + expect(rendered).toBe(expected); + }); + it("converts header one correctly", () => { const markdown = "# Hello, World!"; const expected = `