Merge pull request #850 from Safelite/feature/richardson/SSR-1466
Fix for empty p tag
This commit is contained in:
commit
270d5b95cb
2 changed files with 18 additions and 7 deletions
|
|
@ -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>`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue