Merge branch 'develop' into feature/SSR-1508

This commit is contained in:
Katie Kroell 2024-09-20 15:58:24 -04:00
commit 841d56eeab
2 changed files with 18 additions and 7 deletions

View file

@ -18,7 +18,7 @@ export function stripRteStyle(stringWithStyleTag) {
* @returns {string} converted string wrapped in an <ol>
*/
export function createOrderedListFromStringOfParagraphs(stringOfParagraphs) {
return `<ol>${stringOfParagraphs.replaceAll('<p>', '<li>').replaceAll('</p>', '</li>')}</ol>`;
return `<ol>${stringOfParagraphs.replaceAll('<p></p>', '').replaceAll('<p>', '<li>').replaceAll('</p>', '</li>')}</ol>`;
}
/**

View file

@ -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 = '<p>String one</p><p>String two</p>';
const expected = '<ol><li>String one</li><li>String two</li></ol>';
describe('createOrderedListFromStringOfParagraphs', () => {
test('returns orderedlist from paragraph string', () => {
// Arrange
const testData = '<p>String one</p><p>String two</p>';
const expected = '<ol><li>String one</li><li>String two</li></ol>';
// Assert
expect(createOrderedListFromStringOfParagraphs(testData)).toBe(expected);
// Assert
expect(createOrderedListFromStringOfParagraphs(testData)).toBe(expected);
});
test('returns orderedlist from paragraph string with empty <p> tag', () => {
// Arrange
const testData = '<p>String one</p><p>String two</p><p></p>';
const expected = '<ol><li>String one</li><li>String two</li></ol>';
// Assert
expect(createOrderedListFromStringOfParagraphs(testData)).toBe(expected);
});
});
});