Skip to content

Commit e72a620

Browse files
Merge branch 'next' into bug/CS-43011-dependency-issue
2 parents 836bb51 + 5f4b86e commit e72a620

File tree

11 files changed

+447
-54
lines changed

11 files changed

+447
-54
lines changed

__test__/attributes-to-string.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Attributes to String', () => {
2727

2828
const resultString = attributeToString(attr)
2929

30-
expect(resultString).toEqual(' display-type="display" asset-uid="asset_uid_1" content-type-uid="sys_assets" asset-link="https://image.url/11.jpg" asset-name="11.jpg" asset-type="image/jpeg" type="asset" class-name="embedded-asset" width="25.16914749661705" className="dsd" id="sdf"')
30+
expect(resultString).toEqual(' display-type="display" asset-uid="asset_uid_1" content-type-uid="sys_assets" asset-link="https://image.url/11.jpg" asset-name="11.jpg" asset-type="image/jpeg" type="asset" class-name="embedded-asset" width="25.16914749661705" className="classname" id="img_id"')
3131
done()
3232
})
3333

__test__/json-to-html.test.ts

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import {
2020
plainTextJson,
2121
styleinPJson,
2222
tableJson,
23-
unorderListJson} from './mock/json-element-mock'
23+
unorderListJson,
24+
entryJsonRteWithClass,
25+
entryJsonRteWithId,
26+
entryJsonRteWithIdinAttrs,
27+
jsonRteClassAndIdAttrs,
28+
styleObj} from './mock/json-element-mock'
2429
import {
2530
blockquoteHtml,
2631
codeHtml,
@@ -38,7 +43,12 @@ import {
3843
plainTextHtml,
3944
styleinPHtml,
4045
tableHtml,
41-
unorderListHtml} from './mock/json-element-mock-result'
46+
unorderListHtml,
47+
plainTextHtmlWithClass,
48+
plainTextHtmlWithId,
49+
htmlTextIdInAttrs,
50+
classAndIdAttrsHtml,
51+
styleObjHtml } from './mock/json-element-mock-result'
4252
describe('Node parser paragraph content', () => {
4353
it('Should accept proper values', done => {
4454
const entry = { uid: 'uid'}
@@ -167,10 +177,23 @@ describe('Node parse text Content', () => {
167177
const paths = ['supercharged_rte']
168178

169179
jsonToHTML({ entry, paths})
170-
171180
expect(entry.supercharged_rte).toEqual([plainTextHtml])
172181
done()
173182
})
183+
it('Should return html text with classname', done => {
184+
const entry = entryJsonRteWithClass
185+
const paths = ['json_rte']
186+
jsonToHTML({ entry: entry, paths })
187+
expect(entry.json_rte).toEqual(plainTextHtmlWithClass)
188+
done()
189+
})
190+
it('Should return html text with id', done => {
191+
const entry = entryJsonRteWithId
192+
const paths = ['json_rte']
193+
jsonToHTML({ entry: entry, paths })
194+
expect(entry.json_rte).toEqual(plainTextHtmlWithId)
195+
done()
196+
})
174197
})
175198

176199
describe('Node parse headers content', () => {
@@ -513,4 +536,44 @@ describe('Node parse style attribute', () => {
513536
expect(entry.supercharged_rte).toEqual(styleinPHtml)
514537
done()
515538
})
539+
it('Should return style attribute in headings tag content', done => {
540+
const entry = styleObj
541+
const paths = ['json_rte']
542+
543+
jsonToHTML({ entry, paths})
544+
545+
expect(entry.json_rte).toEqual(styleObjHtml)
546+
done()
547+
})
516548
})
549+
550+
describe('Node parse json_rte Content', () => {
551+
it('Should return html text with classname', done => {
552+
const entry = entryJsonRteWithClass
553+
const paths = ['json_rte']
554+
jsonToHTML({ entry: entry, paths })
555+
expect(entry.json_rte).toEqual(plainTextHtmlWithClass)
556+
done()
557+
})
558+
it('Should return html text with id', done => {
559+
const entry = entryJsonRteWithId
560+
const paths = ['json_rte']
561+
jsonToHTML({ entry: entry, paths })
562+
expect(entry.json_rte).toEqual(plainTextHtmlWithId)
563+
done()
564+
})
565+
it('Should return html text with id in parent tag', done => {
566+
const entry = entryJsonRteWithIdinAttrs
567+
const paths = ['json_rte']
568+
jsonToHTML({ entry: entry, paths })
569+
expect(entry.json_rte).toEqual(htmlTextIdInAttrs)
570+
done()
571+
})
572+
it('Should return html text with class and id in parent tag', done => {
573+
const entry = jsonRteClassAndIdAttrs
574+
const paths = ['json_rte']
575+
jsonToHTML({ entry: entry, paths })
576+
expect(entry.json_rte).toEqual(classAndIdAttrsHtml)
577+
done()
578+
})
579+
})

__test__/mock/json-element-mock-result.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ const h3Html = "<h3><strong><em><u><sub>Mauris venenatis dui id massa sollicitud
66
const h4Html = "<h4><strong><em><u><sub>MaNullam feugiat turpis quis elit interdum, vitae laoreet quam viverra</sub></u></em></strong></h4>"
77
const h5Html = "<h5>Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.</h5>"
88
const h6Html = "<h6>Nunc porta diam vitae purus semper, ut consequat lorem vehicula.</h6>"
9-
const orderListHtml = "<ol><li style=\"text-align:justify;\">Morbi in quam molestie, fermentum diam vitae, bibendum ipsum.</li><li style=\"text-align:justify;\">Pellentesque mattis lacus in quam aliquam congue</li><li style=\"text-align:justify;\">Integer feugiat leo dignissim, lobortis enim vitae, mollis lectus.</li><li style=\"text-align:justify;\">Sed in ante lacinia, molestie metus eu, fringilla sapien.</li></ol>"
10-
const unorderListHtml = "<ul><li>Sed quis metus sed mi hendrerit mollis vel et odio.</li><li>Integer vitae sem dignissim, elementum libero vel, fringilla massa.</li><li>Integer imperdiet arcu sit amet tortor faucibus aliquet.</li><li>Aenean scelerisque velit vitae dui vehicula, at congue massa sagittis.</li></ul>"
9+
const orderListHtml = "<ol class=\"table\" id=\"table_id\"><li style=\"text-align:justify;\">Morbi in quam molestie, fermentum diam vitae, bibendum ipsum.</li><li style=\"text-align:justify;\">Pellentesque mattis lacus in quam aliquam congue</li><li style=\"text-align:justify;\">Integer feugiat leo dignissim, lobortis enim vitae, mollis lectus.</li><li style=\"text-align:justify;\">Sed in ante lacinia, molestie metus eu, fringilla sapien.</li></ol>"
10+
const unorderListHtml = "<ul class=\"table\" id=\"table_id\"><li>Sed quis metus sed mi hendrerit mollis vel et odio.</li><li>Integer vitae sem dignissim, elementum libero vel, fringilla massa.</li><li>Integer imperdiet arcu sit amet tortor faucibus aliquet.</li><li>Aenean scelerisque velit vitae dui vehicula, at congue massa sagittis.</li></ul>"
1111
const imgHtml = "<img src=\"https://image.url/Donald.jog.png\" />"
1212
const tableHtml = "<table><thead><tr><th><p>Header 1</p></th><th><p>Header 2</p></th></tr></thead><tbody><tr><td><p>Body row 1 data 1</p></td><td><p>Body row 1 data 2</p></td></tr><tr><td><p>Body row 2 data 1</p></td><td><p>Body row 2 data 2</p></td></tr></tbody></table>"
1313
const blockquoteHtml = "<blockquote>Praesent eu ex sed nibh venenatis pretium.</blockquote>"
1414
const codeHtml = "<code>Code template.</code>"
1515
const linkInPHtml = "<strong><em><u><sub></sub></u></em></strong><a href=\"LINK.com\">LINK</a>"
1616
const linkInPURLHtml = "<strong><em><u><sub></sub></u></em></strong><a href=\"LINK.com\" target=\"_blank\">LINK</a>"
1717
const styleinPHtml = "<p style=\"text-align:right;\">This is <span>second</span> <u>JSON</u> entry</p><p style=\"text-align:left;\"><a href=\"example.com\" target=\"_blank\">Example</a></p>"
18-
18+
const plainTextHtmlWithClass = "<p class=\"class_p\"><span class=\"yellow\">abc</span><u><span class=\"blue\">ghi</span></u><strong><em><u><span class=\"orange\" id=\"blue\">Basic</span></u></em></strong><h1><span class=\"purple\">abc</span></h1></p>"
19+
const plainTextHtmlWithId = "<p class=\"class_p\"><em><u><span id=\"blue\">data</span></u></em></p>"
20+
const htmlTextIdInAttrs = "<p id=\"id_p\"><em><u>data</u></em></p>"
21+
const classAndIdAttrsHtml = "<a class=\"class_a\" id=\"id_p\" href=\"LINK.com\">link</a><img class=\"class_img\" id=\"id_img\" src=\"https://dummyImage.url/Donald.jog.png\" /><h1 class=\"class_h1\" id=\"id_h1\">heading1</h1><h2 class=\"class_h2\" id=\"id_h2\">heading2</h2><h3 class=\"class_h3\" id=\"id_h3\">heading3</h3><h4 class=\"class_h4\" id=\"id_h4\">heading4</h4><h5 class=\"class_h5\" id=\"id_h5\">heading5</h5><h6 class=\"class_h6\" id=\"id_h6\">heading6</h6>"
22+
const styleObjHtml = "<h1 style=\"text-align:justify;\">heading1</h1><h2 style=\"text-align:left;\">heading2</h2><h3 style=\"text-align:right;\">heading3</h3><h4 style=\"text-align:justify;\">heading4</h4><h5 style=\"text-align:justify;\">heading5</h5><h6 style=\"text-align:justify;\">heading6</h6>"
1923
export {
2024
h1Html,
2125
h2Html,
@@ -34,4 +38,9 @@ export {
3438
blockquoteHtml,
3539
unorderListHtml,
3640
styleinPHtml,
41+
plainTextHtmlWithClass,
42+
plainTextHtmlWithId,
43+
htmlTextIdInAttrs,
44+
classAndIdAttrsHtml,
45+
styleObjHtml
3746
}

0 commit comments

Comments
 (0)