From f554ad4d47dd39e9dd34c488e598fd1533a97c30 Mon Sep 17 00:00:00 2001
From: Bill Richardson
Date: Fri, 20 Sep 2024 15:34:32 -0400
Subject: [PATCH 1/2] Remove empty paragraph tag
---
src/helpers/text-helper.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/helpers/text-helper.js b/src/helpers/text-helper.js
index 220b1d3f..6ff5ad47 100644
--- a/src/helpers/text-helper.js
+++ b/src/helpers/text-helper.js
@@ -18,7 +18,7 @@ export function stripRteStyle(stringWithStyleTag) {
* @returns {string} converted string wrapped in an
*/
export function createOrderedListFromStringOfParagraphs(stringOfParagraphs) {
- return `${stringOfParagraphs.replaceAll('', '
- ').replaceAll('
', '')}`;
+ return `${stringOfParagraphs.replaceAll('', '').replaceAll('', '
- ').replaceAll('', '
')}
`;
}
/**
From 2e687c52456cdb7913dc0aa8cde5f02cf7a49cd6 Mon Sep 17 00:00:00 2001
From: Bill Richardson
Date: Fri, 20 Sep 2024 15:39:02 -0400
Subject: [PATCH 2/2] add test for empty p tag
---
src/helpers/text-helper.spec.js | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/helpers/text-helper.spec.js b/src/helpers/text-helper.spec.js
index fcb7a88d..689d5c59 100644
--- a/src/helpers/text-helper.spec.js
+++ b/src/helpers/text-helper.spec.js
@@ -74,12 +74,23 @@ describe('text-helper', () => {
])('formatAmountInDollars(%s) should return %s', (amount, expected) => {
expect(formatAmountInDollars(amount)).toBe(expected);
});
- test('returns orderedlist from paragraph string', () => {
- // Arrange
- const testData = 'String one
String two
';
- const expected = '- String one
- String two
';
+ describe('createOrderedListFromStringOfParagraphs', () => {
+ test('returns orderedlist from paragraph string', () => {
+ // Arrange
+ const testData = 'String one
String two
';
+ const expected = '- String one
- String two
';
- // Assert
- expect(createOrderedListFromStringOfParagraphs(testData)).toBe(expected);
+ // Assert
+ expect(createOrderedListFromStringOfParagraphs(testData)).toBe(expected);
+ });
+
+ test('returns orderedlist from paragraph string with empty tag', () => {
+ // Arrange
+ const testData = '
String one
String two
';
+ const expected = '- String one
- String two
';
+
+ // Assert
+ expect(createOrderedListFromStringOfParagraphs(testData)).toBe(expected);
+ });
});
});