@@ -20,7 +20,9 @@ import {
2020 plainTextJson ,
2121 styleinPJson ,
2222 tableJson ,
23- unorderListJson } from './mock/json-element-mock'
23+ unorderListJson ,
24+ entryJsonRteWithClass ,
25+ entryJsonRteWithId } from './mock/json-element-mock'
2426import {
2527 blockquoteHtml ,
2628 codeHtml ,
@@ -38,7 +40,9 @@ import {
3840 plainTextHtml ,
3941 styleinPHtml ,
4042 tableHtml ,
41- unorderListHtml } from './mock/json-element-mock-result'
43+ unorderListHtml ,
44+ plainTextHtmlWithClass ,
45+ plainTextHtmlWithId } from './mock/json-element-mock-result'
4246describe ( 'Node parser paragraph content' , ( ) => {
4347 it ( 'Should accept proper values' , done => {
4448 const entry = { uid : 'uid' }
@@ -171,85 +175,17 @@ describe('Node parse text Content', () => {
171175 done ( )
172176 } )
173177 it ( 'Should return html text with classname' , done => {
174- const entry = {
175- "uid" : "" ,
176- "_version" : 3 ,
177- "locale" : "en-us" ,
178- "json_rte" : {
179- "type" : "doc" ,
180- "attrs" : { } ,
181- "uid" : "" ,
182- "children" : [
183- {
184- "type" : "p" ,
185- "attrs" : { class : "class_p" } ,
186- "uid" : "" ,
187- "children" : [
188- {
189- "text" : "abc" ,
190- "classname" : "yellow" ,
191- } ,
192- {
193- "text" : "def" ,
194- "italic" : false ,
195- "underline" : true ,
196- "classname" : "red" ,
197-
198- } ,
199- {
200- "text" : "fed" ,
201- "italic" : true ,
202- "underline" : true ,
203- "classname" : "green" ,
204-
205- } ,
206- {
207- "text" : "ghi" ,
208- "underline" : true ,
209- "classname" : "blue" ,
210- } ,
211- {
212- "text" : "Basic" ,
213- "classname" : "orange" ,
214- "id" : "blue" ,
215- "bold" : true ,
216- "underline" : true ,
217- "italic" : true
218- } ,
219- {
220- "text" : "data" ,
221- "classname" : "brown" ,
222- "id" : "blue" ,
223- "bold" : false ,
224- "underline" : true ,
225- "italic" : true
226- } ,
227- {
228- "type" : "h1" ,
229- "attrs" : { } ,
230- "uid" : "" ,
231- "children" : [
232- {
233- "text" : "abc" ,
234- "classname" : "purple" ,
235- } ,
236- {
237- "text" : "def" ,
238- "italic" : false ,
239- "underline" : true ,
240- "classname" : "white" ,
241- }
242- ]
243- }
244- ]
245- }
246- ] ,
247- "_version" : 3
248- }
249- }
250- const paths = [ 'json_rte' , 'children' ]
251- const response = jsonToHTML ( { entry : entry , paths } )
252- console . log ( "🚀 ~ file: json-to-html.test.ts:193 ~ describe ~ entry.json_rte:" , entry )
178+ const entry = entryJsonRteWithClass
179+ const paths = [ 'json_rte' ]
180+ jsonToHTML ( { entry : entry , paths } )
181+ expect ( entry . json_rte ) . toEqual ( plainTextHtmlWithClass )
182+ done ( )
183+ } )
184+ it ( 'Should return html text with id' , done => {
185+ const entry = entryJsonRteWithId
186+ const paths = [ 'json_rte' ]
187+ jsonToHTML ( { entry : entry , paths } )
188+ expect ( entry . json_rte ) . toEqual ( plainTextHtmlWithId )
253189 done ( )
254190 } )
255191} )
0 commit comments