diff --git a/test/expectedJson.ts b/test/expectedJson.ts index 0540dc5..1509588 100644 --- a/test/expectedJson.ts +++ b/test/expectedJson.ts @@ -1869,5 +1869,46 @@ export default { `, expectedJson: {"type":"doc","uid":"uid","attrs":{},"children":[{"type":"table","attrs":{"style":{},"redactor-attributes":{"border":"1"},"rows":5,"cols":4,"colWidths":[250,250,250,250],"disabledCols":[1,2,3]},"uid":"uid","children":[{"type":"thead","attrs":{},"uid":"uid","children":[{"type":"tr","attrs":{},"uid":"uid","children":[{"type":"th","attrs":{},"uid":"uid","children":[{"text":"Header 1"}]},{"type":"th","attrs":{"colSpan":3,"style":{},"redactor-attributes":{"colspan":"3"}},"uid":"uid","children":[{"text":"Header 2"}]},{"type":"th","attrs":{"void":true},"children":[{"text":""}]},{"type":"th","attrs":{"void":true},"children":[{"text":""}]},{"type":"th","attrs":{},"uid":"uid","children":[{"text":"Header 3"}]}]}]},{"type":"tbody","attrs":{},"uid":"uid","children":[{"type":"trgrp","children":[{"type":"tr","attrs":{},"uid":"uid","children":[{"type":"td","attrs":{"rowSpan":2,"style":{},"redactor-attributes":{"rowspan":"2"}},"uid":"uid","children":[{"text":"Row 1, Col 1"}]},{"type":"td","attrs":{"colSpan":2,"style":{},"redactor-attributes":{"colspan":"2"}},"uid":"uid","children":[{"text":"Row 1, Col 2"}]},{"type":"td","attrs":{"void":true},"children":[{"text":""}]},{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 1, Col 3"}]},{"type":"td","attrs":{"rowSpan":2,"style":{},"redactor-attributes":{"rowspan":"2"}},"uid":"uid","children":[{"text":"Row 1, Col 4"}]}]},{"type":"tr","attrs":{},"uid":"uid","children":[{"type":"td","attrs":{"void":true},"children":[{"text":""}]},{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 2, Col 2"}]},{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 2, Col 3"}]},{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 2, Col 4"}]},{"type":"td","attrs":{"void":true},"children":[{"text":""}]}]}]},{"type":"trgrp","children":[{"type":"tr","attrs":{},"uid":"uid","children":[{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 3, Col 1"}]},{"type":"td","attrs":{"rowSpan":2,"colSpan":3,"style":{},"redactor-attributes":{"colspan":"3","rowspan":"2"}},"uid":"uid","children":[{"text":"Row 3, Col 2"}]},{"type":"td","attrs":{"void":true},"children":[{"text":""}]},{"type":"td","attrs":{"void":true},"children":[{"text":""}]},{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 3, Col 5"}]}]},{"type":"tr","attrs":{},"uid":"uid","children":[{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 4, Col 1"}]},{"type":"td","attrs":{"void":true},"children":[{"text":""}]},{"type":"td","attrs":{"void":true},"children":[{"text":""}]},{"type":"td","attrs":{"void":true},"children":[{"text":""}]},{"type":"td","attrs":{},"uid":"uid","children":[{"text":"Row 4, Col 5"}]}]}]}]}]}]} }, + 'fix_EB-745' : { + html: ``, + expectedJson: { + "uid": "uid", + "type": "doc", + "attrs": {}, + "children": [ + { + "uid": "uid", + "type": "ul", + "children": [ + { + "type": "li", + "uid": "uid", + "attrs": { + "style": {}, + "redactor-attributes": {}, + "dir": "ltr" + }, + "children": [ + { + "text": "Vehicle" + }, + { + "text": "\n", + "break": true + }, + { + "text": "This is test" + } + ] + } + ], + "attrs": { + "style": {} + } + } + ] + } + } } \ No newline at end of file diff --git a/test/toRedactor.test.ts b/test/toRedactor.test.ts index c04f2b5..9cd5805 100644 --- a/test/toRedactor.test.ts +++ b/test/toRedactor.test.ts @@ -237,4 +237,15 @@ describe("Testing json to html conversion", () => { expect(html).toStrictEqual(expectedHtml) }) + test("should not add duplicate
when we have both break and \n together", () => { + let jsonValue = expectedValue["fix_EB-745"].expectedJson + + let htmlValue = toRedactor(jsonValue) + console.log("🚀 ~ test ~ htmlValue:", htmlValue) + console.log(expectedValue["fix_EB-745"].html); + + let testResult = isEqual(htmlValue, expectedValue["fix_EB-745"].html) + expect(testResult).toBe(true) + }) + }) \ No newline at end of file