contentstack_utils 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,643 +1,643 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ContentstackUtils do
4
- describe '#renderContent' do
5
- it 'Render function with blank content and options test' do
6
- expect(makeRenderFunction(nil)).to eq nil
7
- expect(makeRenderFunction('')).to eq ''
8
- expect(makeRenderFunction([''])).to eq ['']
9
- end
10
- it 'Render function with non html content' do
11
- expect(makeRenderFunction(NO_HTML)).to eq NO_HTML
12
- expect(makeRenderFunction([NO_HTML])).to eq [NO_HTML]
13
- end
14
- it 'Render function with html content without Embedded object' do
15
- expect(makeRenderFunction(SIMPLE_HTML)).to eq SIMPLE_HTML
16
- expect(makeRenderFunction([SIMPLE_HTML])).to eq [SIMPLE_HTML]
17
- end
18
- it 'Render function with non html content and blanks' do
19
- expect(makeRenderFunction([NO_HTML, ''])).to eq [NO_HTML, '']
20
- expect(makeRenderFunction([SIMPLE_HTML, NO_HTML])).to eq [SIMPLE_HTML, NO_HTML]
21
- end
22
- it 'Render function with non html content and blanks' do
23
- expect(makeRenderFunction(ENTRY_BLOCK)).to eq ''
24
- expect(makeRenderFunction(ENTRY_INLINE)).to eq ''
25
- expect(makeRenderFunction(ENTRY_LINK)).to eq ''
26
- end
27
- it 'Render Function with Embedded Asset without Options test' do
28
- expect(makeRenderFunction(ASSET_DISPLAY)).to eq ''
29
- expect(makeRenderFunction(ASSET_DOWNLOAD)).to eq ''
30
- end
31
- it 'Render Function with Embedded Entry with Options' do
32
- expect(makeRenderFunction(ENTRY_BLOCK, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
33
- expect(makeRenderFunction(ENTRY_INLINE, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
34
- expect(makeRenderFunction(ENTRY_LINK, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
35
- end
36
- it 'Render Function with Embedded Entry with no items Options' do
37
- expect(makeRenderFunction(ENTRY_BLOCK, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
38
- expect(makeRenderFunction(ENTRY_INLINE, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
39
- expect(makeRenderFunction(ENTRY_LINK, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
40
- end
41
- it 'Render Function with Embedded Asset with Options test' do
42
- expect(makeRenderFunction(ASSET_DISPLAY, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
43
- expect(makeRenderFunction(ASSET_DOWNLOAD, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
44
- expect(makeRenderFunction(ASSET_DISPLAY, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
45
- expect(makeRenderFunction(ASSET_DOWNLOAD, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
46
- end
47
- it 'Render Function string of array with Embedded Entry with Options' do
48
- expect(makeRenderFunction([ENTRY_BLOCK])).to eq ['']
49
- expect(makeRenderFunction([ENTRY_BLOCK, ENTRY_INLINE])).to eq ['', '']
50
- end
51
- it 'Render Function to render Embbedded Asset test' do
52
- expect(makeRenderFunction(ENTRY_EMBEDDED_ASSET['rich_text_editor'], EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ENTRY_ASSET_RICH_TEXT
53
- end
54
- it 'Render Function to render Embbedded Asset with render option test' do
55
- expect(makeRenderFunction(ENTRY_EMBEDDED_ASSET['rich_text_editor'], EMBEDDED_ASSET_WITH_CUSTOM_RENDER_OPTION)).to eq ENTRY_ASSET_RICH_TEXT_RENDER_OPTION
56
- end
57
- it 'Render Function to render Embedded Entries with out render option test' do
58
- expect(makeRenderFunction(ENTRY_EMBEDDED_ENTRIES['rich_text_editor'], EMBEDDED_ENTRY_WITH_DEFAULT_RENDER_OPTION)).to eq ENTRY_MULTIPLE_RICH_TEXT
59
- end
60
- end
61
-
62
-
63
- describe '#JsonToHtml Array' do
64
- it 'Should return blank string for blank doc' do
65
- doc = getJson(BlankDocument)
66
-
67
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
68
-
69
- expect(result).to eq [""]
70
- end
71
-
72
- it 'Should return mark text string for PlainTextJson doc' do
73
- doc = getJson(PlainTextJson)
74
-
75
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
76
-
77
- expect(result).to eq [PlainTextHtml]
78
- end
79
-
80
- it 'Should return paragraph string for ParagraphJson doc' do
81
- doc = getJson(ParagraphJson)
82
-
83
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
84
-
85
- expect(result).to eq [ParagraphHtml]
86
- end
87
-
88
- it 'Should return H1 string for H1Json doc' do
89
- doc = getJson(H1Json)
90
-
91
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
92
-
93
- expect(result).to eq [H1Html]
94
- end
95
-
96
- it 'Should return H2 string for H2Json doc' do
97
- doc = getJson(H2Json)
98
-
99
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
100
-
101
- expect(result).to eq [H2Html]
102
- end
103
-
104
- it 'Should return H3 string for H3Json doc' do
105
- doc = getJson(H3Json)
106
-
107
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
108
-
109
- expect(result).to eq [H3Html]
110
- end
111
-
112
- it 'Should return H4 string for H4Json doc' do
113
- doc = getJson(H4Json)
114
-
115
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
116
-
117
- expect(result).to eq [H4Html]
118
- end
119
-
120
- it 'Should return H5 string for H5Json doc' do
121
- doc = getJson(H5Json)
122
-
123
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
124
-
125
- expect(result).to eq [H5Html]
126
- end
127
-
128
- it 'Should return H6 string for H6Json doc' do
129
- doc = getJson(H6Json)
130
-
131
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
132
-
133
- expect(result).to eq [H6Html]
134
- end
135
-
136
- it 'Should return Order List string for OrderListJson doc' do
137
- doc = getJson(OrderListJson)
138
-
139
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
140
-
141
- expect(result).to eq [OrderListHtml]
142
- end
143
-
144
- it 'Should return Unorder List string for UnorderListJson doc' do
145
- doc = getJson(UnorderListJson)
146
-
147
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
148
-
149
- expect(result).to eq [UnorderListHtml]
150
- end
151
-
152
- it 'Should return image string for ImgJson doc' do
153
- doc = getJson(ImgJson)
154
-
155
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
156
-
157
- expect(result).to eq [ImgHtml]
158
- end
159
-
160
- it 'Should return Blockquote string for BlockquoteJson doc' do
161
- doc = getJson(BlockquoteJson)
162
-
163
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
164
-
165
- expect(result).to eq [BlockquoteHtml]
166
- end
167
-
168
- it 'Should return Code string for CodeJson doc' do
169
- doc = getJson(CodeJson)
170
-
171
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
172
-
173
- expect(result).to eq [CodeHtml]
174
- end
175
-
176
- it 'Should return Table string for TableJson doc' do
177
- doc = getJson(TableJson)
178
-
179
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
180
-
181
- expect(result).to eq [TableHtml]
182
- end
183
-
184
- it 'Should return Link string for LinkInPJson doc' do
185
- doc = getJson(LinkInPJson)
186
-
187
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
188
-
189
- expect(result).to eq [LinkInPHtml]
190
- end
191
-
192
- it 'Should return Embed string for EmbedJson doc' do
193
- doc = getJson(EmbedJson)
194
-
195
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
196
-
197
- expect(result).to eq [EmbedHtml]
198
- end
199
-
200
- it 'Should return horizontal line string for horizontal line doc' do
201
- doc = getJson(HRJson)
202
-
203
- result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
204
-
205
- expect(result).to eq ['<hr />']
206
- end
207
- end
208
-
209
- describe '#JsonToHtml' do
210
- it 'Should return blank string for blank doc' do
211
- doc = getJson(BlankDocument)
212
-
213
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
214
-
215
- expect(result).to eq ""
216
- end
217
-
218
- it 'Should return mark text string for PlainTextJson doc' do
219
- doc = getJson(PlainTextJson)
220
-
221
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
222
-
223
- expect(result).to eq PlainTextHtml
224
- end
225
-
226
- it 'Should return paragraph string for ParagraphJson doc' do
227
- doc = getJson(ParagraphJson)
228
-
229
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
230
-
231
- expect(result).to eq ParagraphHtml
232
- end
233
-
234
- it 'Should return H1 string for H1Json doc' do
235
- doc = getJson(H1Json)
236
-
237
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
238
-
239
- expect(result).to eq H1Html
240
- end
241
-
242
- it 'Should return H2 string for H2Json doc' do
243
- doc = getJson(H2Json)
244
-
245
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
246
-
247
- expect(result).to eq H2Html
248
- end
249
-
250
- it 'Should return H3 string for H3Json doc' do
251
- doc = getJson(H3Json)
252
-
253
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
254
-
255
- expect(result).to eq H3Html
256
- end
257
-
258
- it 'Should return H4 string for H4Json doc' do
259
- doc = getJson(H4Json)
260
-
261
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
262
-
263
- expect(result).to eq H4Html
264
- end
265
-
266
- it 'Should return H5 string for H5Json doc' do
267
- doc = getJson(H5Json)
268
-
269
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
270
-
271
- expect(result).to eq H5Html
272
- end
273
-
274
- it 'Should return H6 string for H6Json doc' do
275
- doc = getJson(H6Json)
276
-
277
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
278
-
279
- expect(result).to eq H6Html
280
- end
281
-
282
- it 'Should return Order List string for OrderListJson doc' do
283
- doc = getJson(OrderListJson)
284
-
285
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
286
-
287
- expect(result).to eq OrderListHtml
288
- end
289
-
290
- it 'Should return Unorder List string for UnorderListJson doc' do
291
- doc = getJson(UnorderListJson)
292
-
293
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
294
-
295
- expect(result).to eq UnorderListHtml
296
- end
297
-
298
- it 'Should return image string for ImgJson doc' do
299
- doc = getJson(ImgJson)
300
-
301
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
302
-
303
- expect(result).to eq ImgHtml
304
- end
305
-
306
- it 'Should return Blockquote string for BlockquoteJson doc' do
307
- doc = getJson(BlockquoteJson)
308
-
309
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
310
-
311
- expect(result).to eq BlockquoteHtml
312
- end
313
-
314
- it 'Should return Code string for CodeJson doc' do
315
- doc = getJson(CodeJson)
316
-
317
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
318
-
319
- expect(result).to eq CodeHtml
320
- end
321
-
322
- it 'Should return Table string for TableJson doc' do
323
- doc = getJson(TableJson)
324
-
325
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
326
-
327
- expect(result).to eq TableHtml
328
- end
329
-
330
- it 'Should return Link string for LinkInPJson doc' do
331
- doc = getJson(LinkInPJson)
332
-
333
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
334
-
335
- expect(result).to eq LinkInPHtml
336
- end
337
-
338
- it 'Should return Embed string for EmbedJson doc' do
339
- doc = getJson(EmbedJson)
340
-
341
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
342
-
343
- expect(result).to eq EmbedHtml
344
- end
345
-
346
- it 'Should return horizontal line string for horizontal line doc' do
347
- doc = getJson(HRJson)
348
-
349
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
350
-
351
- expect(result).to eq '<hr />'
352
- end
353
-
354
- it 'Should return horizontal line string for horizontal line doc' do
355
- doc = getJson(H1NonChildJson)
356
-
357
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
358
-
359
- expect(result).to eq '<h1></h1>'
360
- end
361
- end
362
-
363
- describe '#JsonToHtml reference' do
364
- it 'Should return blank string for non entry option' do
365
- doc = getJson(AssetReferenceJson)
366
-
367
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
368
-
369
- expect(result).to eq ''
370
- end
371
-
372
- it 'Should return asset embedded items' do
373
- doc = getJson(AssetReferenceJson)
374
-
375
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
376
-
377
- expect(result).to eq AssetReferenceHtml
378
- end
379
-
380
- it 'Should return entry block embedded items' do
381
- doc = getJson(EntryReferenceBlockJson)
382
-
383
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
384
-
385
- expect(result).to eq EntryReferenceBlockHtml
386
- end
387
-
388
- it 'Should return entry link embedded items' do
389
- doc = getJson(EntryReferenceLinkJson)
390
-
391
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
392
-
393
- expect(result).to eq EntryReferenceLinkHtml
394
- end
395
-
396
- it 'Should return entry inline embedded items' do
397
- doc = getJson(EntryReferenceInlineJson)
398
-
399
- result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
400
-
401
- expect(result).to eq EntryReferenceInlineHtml
402
- end
403
-
404
-
405
- end
406
- describe 'GQL #JsonToHtml' do
407
- it 'Should return blank string for blank doc' do
408
- entry = getGQLJSONRTE(BlankDocument)
409
-
410
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
411
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
412
-
413
- expect(result).to eq ""
414
- expect(arrayResult).to eq [""]
415
- end
416
-
417
- it 'Should return mark text string for PlainTextJson doc' do
418
- entry = getGQLJSONRTE(PlainTextJson)
419
-
420
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
421
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
422
-
423
- expect(result).to eq PlainTextHtml
424
- expect(arrayResult).to eq [PlainTextHtml]
425
- end
426
-
427
- it 'Should return paragraph string for ParagraphJson doc' do
428
- entry = getGQLJSONRTE(ParagraphJson)
429
-
430
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
431
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
432
-
433
- expect(result).to eq ParagraphHtml
434
- expect(arrayResult).to eq [ParagraphHtml]
435
- end
436
-
437
- it 'Should return H1 string for H1Json doc' do
438
- entry = getGQLJSONRTE(H1Json)
439
-
440
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
441
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
442
-
443
- expect(result).to eq H1Html
444
- expect(arrayResult).to eq [H1Html]
445
- end
446
-
447
- it 'Should return H2 string for H1Json doc' do
448
- entry = getGQLJSONRTE(H2Json)
449
-
450
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
451
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
452
-
453
- expect(result).to eq H2Html
454
- expect(arrayResult).to eq [H2Html]
455
- end
456
-
457
- it 'Should return H3 string for H1Json doc' do
458
- entry = getGQLJSONRTE(H3Json)
459
-
460
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
461
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
462
-
463
- expect(result).to eq H3Html
464
- expect(arrayResult).to eq [H3Html]
465
- end
466
-
467
- it 'Should return H4 string for H1Json doc' do
468
- entry = getGQLJSONRTE(H4Json)
469
-
470
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
471
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
472
-
473
- expect(result).to eq H4Html
474
- expect(arrayResult).to eq [H4Html]
475
- end
476
-
477
- it 'Should return H5 string for H1Json doc' do
478
- entry = getGQLJSONRTE(H5Json)
479
-
480
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
481
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
482
-
483
- expect(result).to eq H5Html
484
- expect(arrayResult).to eq [H5Html]
485
- end
486
-
487
- it 'Should return H6 string for H1Json doc' do
488
- entry = getGQLJSONRTE(H6Json)
489
-
490
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
491
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
492
-
493
- expect(result).to eq H6Html
494
- expect(arrayResult).to eq [H6Html]
495
- end
496
-
497
- it 'Should return Order List string for OrderListJson doc' do
498
- entry = getGQLJSONRTE(OrderListJson)
499
-
500
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
501
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
502
-
503
- expect(result).to eq OrderListHtml
504
- expect(arrayResult).to eq [OrderListHtml]
505
- end
506
-
507
- it 'Should return Unorder List string for UnorderListJson doc' do
508
- entry = getGQLJSONRTE(UnorderListJson)
509
-
510
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
511
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
512
-
513
- expect(result).to eq UnorderListHtml
514
- expect(arrayResult).to eq [UnorderListHtml]
515
- end
516
-
517
- it 'Should return image string for ImgJson doc' do
518
- entry = getGQLJSONRTE(ImgJson)
519
-
520
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
521
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
522
-
523
- expect(result).to eq ImgHtml
524
- expect(arrayResult).to eq [ImgHtml]
525
- end
526
-
527
- it 'Should return Blockquote string for BlockquoteJson doc' do
528
- entry = getGQLJSONRTE(BlockquoteJson)
529
-
530
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
531
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
532
-
533
- expect(result).to eq BlockquoteHtml
534
- expect(arrayResult).to eq [BlockquoteHtml]
535
- end
536
-
537
- it 'Should return Code string for CodeJson doc' do
538
- entry = getGQLJSONRTE(CodeJson)
539
-
540
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
541
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
542
-
543
- expect(result).to eq CodeHtml
544
- expect(arrayResult).to eq [CodeHtml]
545
- end
546
-
547
- it 'Should return Table string for TableJson doc' do
548
- entry = getGQLJSONRTE(TableJson)
549
-
550
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
551
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
552
-
553
- expect(result).to eq TableHtml
554
- expect(arrayResult).to eq [TableHtml]
555
- end
556
-
557
- it 'Should return Link string for LinkInPJson doc' do
558
- entry = getGQLJSONRTE(LinkInPJson)
559
-
560
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
561
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
562
-
563
- expect(result).to eq LinkInPHtml
564
- expect(arrayResult).to eq [LinkInPHtml]
565
- end
566
-
567
- it 'Should return Embed string for EmbedJson doc' do
568
- entry = getGQLJSONRTE(EmbedJson)
569
-
570
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
571
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
572
-
573
- expect(result).to eq EmbedHtml
574
- expect(arrayResult).to eq [EmbedHtml]
575
- end
576
-
577
- it 'Should return horizontal line string for horizontal line doc' do
578
- entry = getGQLJSONRTE(HRJson)
579
-
580
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
581
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
582
-
583
- expect(result).to eq '<hr />'
584
- expect(arrayResult).to eq ['<hr />']
585
- end
586
- end
587
-
588
- describe 'GQL #JsonToHtml reference' do
589
- it 'Should return blank string for non entry option' do
590
- entry = getGQLJSONRTE(AssetReferenceJson)
591
-
592
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
593
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
594
-
595
- expect(result).to eq ''
596
- expect(arrayResult).to eq ['']
597
- end
598
-
599
- it 'Should return asset embedded items' do
600
- entry = getGQLJSONRTE(AssetReferenceJson, EmbedEdges)
601
-
602
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
603
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
604
-
605
- expect(result).to eq AssetReferenceHtml
606
- expect(arrayResult).to eq [AssetReferenceHtml]
607
- end
608
-
609
- it 'Should return entry block embedded items' do
610
- entry = getGQLJSONRTE(EntryReferenceBlockJson, EmbedEdges)
611
-
612
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
613
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
614
-
615
- expect(result).to eq EntryReferenceBlockHtml
616
- expect(arrayResult).to eq [EntryReferenceBlockHtml]
617
- end
618
-
619
- it 'Should return entry link embedded items' do
620
- entry = getGQLJSONRTE(EntryReferenceLinkJson, EmbedEdges)
621
-
622
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
623
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
624
-
625
- expect(result).to eq EntryReferenceLinkHtml
626
- expect(arrayResult).to eq [EntryReferenceLinkHtml]
627
- end
628
-
629
- it 'Should return entry inline embedded items' do
630
- entry = getGQLJSONRTE(EntryReferenceInlineJson, EmbedEdges)
631
-
632
- result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
633
- arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
634
-
635
- expect(result).to eq EntryReferenceInlineHtml
636
- expect(arrayResult).to eq [EntryReferenceInlineHtml]
637
- end
638
- end
639
-
640
- def makeRenderFunction(content, option = ContentstackUtils::Model::Options.new(ENTRY_EMBEDDED_ASSET))
641
- ContentstackUtils.render_content(content, option)
642
- end
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ContentstackUtils do
4
+ describe '#renderContent' do
5
+ it 'Render function with blank content and options test' do
6
+ expect(makeRenderFunction(nil)).to eq nil
7
+ expect(makeRenderFunction('')).to eq ''
8
+ expect(makeRenderFunction([''])).to eq ['']
9
+ end
10
+ it 'Render function with non html content' do
11
+ expect(makeRenderFunction(NO_HTML)).to eq NO_HTML
12
+ expect(makeRenderFunction([NO_HTML])).to eq [NO_HTML]
13
+ end
14
+ it 'Render function with html content without Embedded object' do
15
+ expect(makeRenderFunction(SIMPLE_HTML)).to eq SIMPLE_HTML
16
+ expect(makeRenderFunction([SIMPLE_HTML])).to eq [SIMPLE_HTML]
17
+ end
18
+ it 'Render function with non html content and blanks' do
19
+ expect(makeRenderFunction([NO_HTML, ''])).to eq [NO_HTML, '']
20
+ expect(makeRenderFunction([SIMPLE_HTML, NO_HTML])).to eq [SIMPLE_HTML, NO_HTML]
21
+ end
22
+ it 'Render function with non html content and blanks' do
23
+ expect(makeRenderFunction(ENTRY_BLOCK)).to eq ''
24
+ expect(makeRenderFunction(ENTRY_INLINE)).to eq ''
25
+ expect(makeRenderFunction(ENTRY_LINK)).to eq ''
26
+ end
27
+ it 'Render Function with Embedded Asset without Options test' do
28
+ expect(makeRenderFunction(ASSET_DISPLAY)).to eq ''
29
+ expect(makeRenderFunction(ASSET_DOWNLOAD)).to eq ''
30
+ end
31
+ it 'Render Function with Embedded Entry with Options' do
32
+ expect(makeRenderFunction(ENTRY_BLOCK, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
33
+ expect(makeRenderFunction(ENTRY_INLINE, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
34
+ expect(makeRenderFunction(ENTRY_LINK, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
35
+ end
36
+ it 'Render Function with Embedded Entry with no items Options' do
37
+ expect(makeRenderFunction(ENTRY_BLOCK, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
38
+ expect(makeRenderFunction(ENTRY_INLINE, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
39
+ expect(makeRenderFunction(ENTRY_LINK, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
40
+ end
41
+ it 'Render Function with Embedded Asset with Options test' do
42
+ expect(makeRenderFunction(ASSET_DISPLAY, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
43
+ expect(makeRenderFunction(ASSET_DOWNLOAD, EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ''
44
+ expect(makeRenderFunction(ASSET_DISPLAY, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
45
+ expect(makeRenderFunction(ASSET_DOWNLOAD, EMBEDDED_ASSET_WITH_NO_ASSET_OBJECT)).to eq ''
46
+ end
47
+ it 'Render Function string of array with Embedded Entry with Options' do
48
+ expect(makeRenderFunction([ENTRY_BLOCK])).to eq ['']
49
+ expect(makeRenderFunction([ENTRY_BLOCK, ENTRY_INLINE])).to eq ['', '']
50
+ end
51
+ it 'Render Function to render Embbedded Asset test' do
52
+ expect(makeRenderFunction(ENTRY_EMBEDDED_ASSET['rich_text_editor'], EMBEDDED_ASSET_WITH_DEFAULT_RENDER_OPTION)).to eq ENTRY_ASSET_RICH_TEXT
53
+ end
54
+ it 'Render Function to render Embbedded Asset with render option test' do
55
+ expect(makeRenderFunction(ENTRY_EMBEDDED_ASSET['rich_text_editor'], EMBEDDED_ASSET_WITH_CUSTOM_RENDER_OPTION)).to eq ENTRY_ASSET_RICH_TEXT_RENDER_OPTION
56
+ end
57
+ it 'Render Function to render Embedded Entries with out render option test' do
58
+ expect(makeRenderFunction(ENTRY_EMBEDDED_ENTRIES['rich_text_editor'], EMBEDDED_ENTRY_WITH_DEFAULT_RENDER_OPTION)).to eq ENTRY_MULTIPLE_RICH_TEXT
59
+ end
60
+ end
61
+
62
+
63
+ describe '#JsonToHtml Array' do
64
+ it 'Should return blank string for blank doc' do
65
+ doc = getJson(BlankDocument)
66
+
67
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
68
+
69
+ expect(result).to eq [""]
70
+ end
71
+
72
+ it 'Should return mark text string for PlainTextJson doc' do
73
+ doc = getJson(PlainTextJson)
74
+
75
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
76
+
77
+ expect(result).to eq [PlainTextHtml]
78
+ end
79
+
80
+ it 'Should return paragraph string for ParagraphJson doc' do
81
+ doc = getJson(ParagraphJson)
82
+
83
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
84
+
85
+ expect(result).to eq [ParagraphHtml]
86
+ end
87
+
88
+ it 'Should return H1 string for H1Json doc' do
89
+ doc = getJson(H1Json)
90
+
91
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
92
+
93
+ expect(result).to eq [H1Html]
94
+ end
95
+
96
+ it 'Should return H2 string for H2Json doc' do
97
+ doc = getJson(H2Json)
98
+
99
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
100
+
101
+ expect(result).to eq [H2Html]
102
+ end
103
+
104
+ it 'Should return H3 string for H3Json doc' do
105
+ doc = getJson(H3Json)
106
+
107
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
108
+
109
+ expect(result).to eq [H3Html]
110
+ end
111
+
112
+ it 'Should return H4 string for H4Json doc' do
113
+ doc = getJson(H4Json)
114
+
115
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
116
+
117
+ expect(result).to eq [H4Html]
118
+ end
119
+
120
+ it 'Should return H5 string for H5Json doc' do
121
+ doc = getJson(H5Json)
122
+
123
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
124
+
125
+ expect(result).to eq [H5Html]
126
+ end
127
+
128
+ it 'Should return H6 string for H6Json doc' do
129
+ doc = getJson(H6Json)
130
+
131
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
132
+
133
+ expect(result).to eq [H6Html]
134
+ end
135
+
136
+ it 'Should return Order List string for OrderListJson doc' do
137
+ doc = getJson(OrderListJson)
138
+
139
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
140
+
141
+ expect(result).to eq [OrderListHtml]
142
+ end
143
+
144
+ it 'Should return Unorder List string for UnorderListJson doc' do
145
+ doc = getJson(UnorderListJson)
146
+
147
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
148
+
149
+ expect(result).to eq [UnorderListHtml]
150
+ end
151
+
152
+ it 'Should return image string for ImgJson doc' do
153
+ doc = getJson(ImgJson)
154
+
155
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
156
+
157
+ expect(result).to eq [ImgHtml]
158
+ end
159
+
160
+ it 'Should return Blockquote string for BlockquoteJson doc' do
161
+ doc = getJson(BlockquoteJson)
162
+
163
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
164
+
165
+ expect(result).to eq [BlockquoteHtml]
166
+ end
167
+
168
+ it 'Should return Code string for CodeJson doc' do
169
+ doc = getJson(CodeJson)
170
+
171
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
172
+
173
+ expect(result).to eq [CodeHtml]
174
+ end
175
+
176
+ it 'Should return Table string for TableJson doc' do
177
+ doc = getJson(TableJson)
178
+
179
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
180
+
181
+ expect(result).to eq [TableHtml]
182
+ end
183
+
184
+ it 'Should return Link string for LinkInPJson doc' do
185
+ doc = getJson(LinkInPJson)
186
+
187
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
188
+
189
+ expect(result).to eq [LinkInPHtml]
190
+ end
191
+
192
+ it 'Should return Embed string for EmbedJson doc' do
193
+ doc = getJson(EmbedJson)
194
+
195
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
196
+
197
+ expect(result).to eq [EmbedHtml]
198
+ end
199
+
200
+ it 'Should return horizontal line string for horizontal line doc' do
201
+ doc = getJson(HRJson)
202
+
203
+ result = ContentstackUtils.json_to_html([doc], ContentstackUtils::Model::Options.new())
204
+
205
+ expect(result).to eq ['<hr />']
206
+ end
207
+ end
208
+
209
+ describe '#JsonToHtml' do
210
+ it 'Should return blank string for blank doc' do
211
+ doc = getJson(BlankDocument)
212
+
213
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
214
+
215
+ expect(result).to eq ""
216
+ end
217
+
218
+ it 'Should return mark text string for PlainTextJson doc' do
219
+ doc = getJson(PlainTextJson)
220
+
221
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
222
+
223
+ expect(result).to eq PlainTextHtml
224
+ end
225
+
226
+ it 'Should return paragraph string for ParagraphJson doc' do
227
+ doc = getJson(ParagraphJson)
228
+
229
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
230
+
231
+ expect(result).to eq ParagraphHtml
232
+ end
233
+
234
+ it 'Should return H1 string for H1Json doc' do
235
+ doc = getJson(H1Json)
236
+
237
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
238
+
239
+ expect(result).to eq H1Html
240
+ end
241
+
242
+ it 'Should return H2 string for H2Json doc' do
243
+ doc = getJson(H2Json)
244
+
245
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
246
+
247
+ expect(result).to eq H2Html
248
+ end
249
+
250
+ it 'Should return H3 string for H3Json doc' do
251
+ doc = getJson(H3Json)
252
+
253
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
254
+
255
+ expect(result).to eq H3Html
256
+ end
257
+
258
+ it 'Should return H4 string for H4Json doc' do
259
+ doc = getJson(H4Json)
260
+
261
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
262
+
263
+ expect(result).to eq H4Html
264
+ end
265
+
266
+ it 'Should return H5 string for H5Json doc' do
267
+ doc = getJson(H5Json)
268
+
269
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
270
+
271
+ expect(result).to eq H5Html
272
+ end
273
+
274
+ it 'Should return H6 string for H6Json doc' do
275
+ doc = getJson(H6Json)
276
+
277
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
278
+
279
+ expect(result).to eq H6Html
280
+ end
281
+
282
+ it 'Should return Order List string for OrderListJson doc' do
283
+ doc = getJson(OrderListJson)
284
+
285
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
286
+
287
+ expect(result).to eq OrderListHtml
288
+ end
289
+
290
+ it 'Should return Unorder List string for UnorderListJson doc' do
291
+ doc = getJson(UnorderListJson)
292
+
293
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
294
+
295
+ expect(result).to eq UnorderListHtml
296
+ end
297
+
298
+ it 'Should return image string for ImgJson doc' do
299
+ doc = getJson(ImgJson)
300
+
301
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
302
+
303
+ expect(result).to eq ImgHtml
304
+ end
305
+
306
+ it 'Should return Blockquote string for BlockquoteJson doc' do
307
+ doc = getJson(BlockquoteJson)
308
+
309
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
310
+
311
+ expect(result).to eq BlockquoteHtml
312
+ end
313
+
314
+ it 'Should return Code string for CodeJson doc' do
315
+ doc = getJson(CodeJson)
316
+
317
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
318
+
319
+ expect(result).to eq CodeHtml
320
+ end
321
+
322
+ it 'Should return Table string for TableJson doc' do
323
+ doc = getJson(TableJson)
324
+
325
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
326
+
327
+ expect(result).to eq TableHtml
328
+ end
329
+
330
+ it 'Should return Link string for LinkInPJson doc' do
331
+ doc = getJson(LinkInPJson)
332
+
333
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
334
+
335
+ expect(result).to eq LinkInPHtml
336
+ end
337
+
338
+ it 'Should return Embed string for EmbedJson doc' do
339
+ doc = getJson(EmbedJson)
340
+
341
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
342
+
343
+ expect(result).to eq EmbedHtml
344
+ end
345
+
346
+ it 'Should return horizontal line string for horizontal line doc' do
347
+ doc = getJson(HRJson)
348
+
349
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
350
+
351
+ expect(result).to eq '<hr />'
352
+ end
353
+
354
+ it 'Should return horizontal line string for horizontal line doc' do
355
+ doc = getJson(H1NonChildJson)
356
+
357
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
358
+
359
+ expect(result).to eq '<h1></h1>'
360
+ end
361
+ end
362
+
363
+ describe '#JsonToHtml reference' do
364
+ it 'Should return blank string for non entry option' do
365
+ doc = getJson(AssetReferenceJson)
366
+
367
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new())
368
+
369
+ expect(result).to eq ''
370
+ end
371
+
372
+ it 'Should return asset embedded items' do
373
+ doc = getJson(AssetReferenceJson)
374
+
375
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
376
+
377
+ expect(result).to eq AssetReferenceHtml
378
+ end
379
+
380
+ it 'Should return entry block embedded items' do
381
+ doc = getJson(EntryReferenceBlockJson)
382
+
383
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
384
+
385
+ expect(result).to eq EntryReferenceBlockHtml
386
+ end
387
+
388
+ it 'Should return entry link embedded items' do
389
+ doc = getJson(EntryReferenceLinkJson)
390
+
391
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
392
+
393
+ expect(result).to eq EntryReferenceLinkHtml
394
+ end
395
+
396
+ it 'Should return entry inline embedded items' do
397
+ doc = getJson(EntryReferenceInlineJson)
398
+
399
+ result = ContentstackUtils.json_to_html(doc, ContentstackUtils::Model::Options.new(JSON_EMBEDDED_ITEMS_ENTRY))
400
+
401
+ expect(result).to eq EntryReferenceInlineHtml
402
+ end
403
+
404
+
405
+ end
406
+ describe 'GQL #JsonToHtml' do
407
+ it 'Should return blank string for blank doc' do
408
+ entry = getGQLJSONRTE(BlankDocument)
409
+
410
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
411
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
412
+
413
+ expect(result).to eq ""
414
+ expect(arrayResult).to eq [""]
415
+ end
416
+
417
+ it 'Should return mark text string for PlainTextJson doc' do
418
+ entry = getGQLJSONRTE(PlainTextJson)
419
+
420
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
421
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
422
+
423
+ expect(result).to eq PlainTextHtml
424
+ expect(arrayResult).to eq [PlainTextHtml]
425
+ end
426
+
427
+ it 'Should return paragraph string for ParagraphJson doc' do
428
+ entry = getGQLJSONRTE(ParagraphJson)
429
+
430
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
431
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
432
+
433
+ expect(result).to eq ParagraphHtml
434
+ expect(arrayResult).to eq [ParagraphHtml]
435
+ end
436
+
437
+ it 'Should return H1 string for H1Json doc' do
438
+ entry = getGQLJSONRTE(H1Json)
439
+
440
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
441
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
442
+
443
+ expect(result).to eq H1Html
444
+ expect(arrayResult).to eq [H1Html]
445
+ end
446
+
447
+ it 'Should return H2 string for H1Json doc' do
448
+ entry = getGQLJSONRTE(H2Json)
449
+
450
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
451
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
452
+
453
+ expect(result).to eq H2Html
454
+ expect(arrayResult).to eq [H2Html]
455
+ end
456
+
457
+ it 'Should return H3 string for H1Json doc' do
458
+ entry = getGQLJSONRTE(H3Json)
459
+
460
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
461
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
462
+
463
+ expect(result).to eq H3Html
464
+ expect(arrayResult).to eq [H3Html]
465
+ end
466
+
467
+ it 'Should return H4 string for H1Json doc' do
468
+ entry = getGQLJSONRTE(H4Json)
469
+
470
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
471
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
472
+
473
+ expect(result).to eq H4Html
474
+ expect(arrayResult).to eq [H4Html]
475
+ end
476
+
477
+ it 'Should return H5 string for H1Json doc' do
478
+ entry = getGQLJSONRTE(H5Json)
479
+
480
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
481
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
482
+
483
+ expect(result).to eq H5Html
484
+ expect(arrayResult).to eq [H5Html]
485
+ end
486
+
487
+ it 'Should return H6 string for H1Json doc' do
488
+ entry = getGQLJSONRTE(H6Json)
489
+
490
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
491
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
492
+
493
+ expect(result).to eq H6Html
494
+ expect(arrayResult).to eq [H6Html]
495
+ end
496
+
497
+ it 'Should return Order List string for OrderListJson doc' do
498
+ entry = getGQLJSONRTE(OrderListJson)
499
+
500
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
501
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
502
+
503
+ expect(result).to eq OrderListHtml
504
+ expect(arrayResult).to eq [OrderListHtml]
505
+ end
506
+
507
+ it 'Should return Unorder List string for UnorderListJson doc' do
508
+ entry = getGQLJSONRTE(UnorderListJson)
509
+
510
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
511
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
512
+
513
+ expect(result).to eq UnorderListHtml
514
+ expect(arrayResult).to eq [UnorderListHtml]
515
+ end
516
+
517
+ it 'Should return image string for ImgJson doc' do
518
+ entry = getGQLJSONRTE(ImgJson)
519
+
520
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
521
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
522
+
523
+ expect(result).to eq ImgHtml
524
+ expect(arrayResult).to eq [ImgHtml]
525
+ end
526
+
527
+ it 'Should return Blockquote string for BlockquoteJson doc' do
528
+ entry = getGQLJSONRTE(BlockquoteJson)
529
+
530
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
531
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
532
+
533
+ expect(result).to eq BlockquoteHtml
534
+ expect(arrayResult).to eq [BlockquoteHtml]
535
+ end
536
+
537
+ it 'Should return Code string for CodeJson doc' do
538
+ entry = getGQLJSONRTE(CodeJson)
539
+
540
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
541
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
542
+
543
+ expect(result).to eq CodeHtml
544
+ expect(arrayResult).to eq [CodeHtml]
545
+ end
546
+
547
+ it 'Should return Table string for TableJson doc' do
548
+ entry = getGQLJSONRTE(TableJson)
549
+
550
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
551
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
552
+
553
+ expect(result).to eq TableHtml
554
+ expect(arrayResult).to eq [TableHtml]
555
+ end
556
+
557
+ it 'Should return Link string for LinkInPJson doc' do
558
+ entry = getGQLJSONRTE(LinkInPJson)
559
+
560
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
561
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
562
+
563
+ expect(result).to eq LinkInPHtml
564
+ expect(arrayResult).to eq [LinkInPHtml]
565
+ end
566
+
567
+ it 'Should return Embed string for EmbedJson doc' do
568
+ entry = getGQLJSONRTE(EmbedJson)
569
+
570
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
571
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
572
+
573
+ expect(result).to eq EmbedHtml
574
+ expect(arrayResult).to eq [EmbedHtml]
575
+ end
576
+
577
+ it 'Should return horizontal line string for horizontal line doc' do
578
+ entry = getGQLJSONRTE(HRJson)
579
+
580
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
581
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
582
+
583
+ expect(result).to eq '<hr />'
584
+ expect(arrayResult).to eq ['<hr />']
585
+ end
586
+ end
587
+
588
+ describe 'GQL #JsonToHtml reference' do
589
+ it 'Should return blank string for non entry option' do
590
+ entry = getGQLJSONRTE(AssetReferenceJson)
591
+
592
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
593
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
594
+
595
+ expect(result).to eq ''
596
+ expect(arrayResult).to eq ['']
597
+ end
598
+
599
+ it 'Should return asset embedded items' do
600
+ entry = getGQLJSONRTE(AssetReferenceJson, EmbedEdges)
601
+
602
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
603
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
604
+
605
+ expect(result).to eq AssetReferenceHtml
606
+ expect(arrayResult).to eq [AssetReferenceHtml]
607
+ end
608
+
609
+ it 'Should return entry block embedded items' do
610
+ entry = getGQLJSONRTE(EntryReferenceBlockJson, EmbedEdges)
611
+
612
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
613
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
614
+
615
+ expect(result).to eq EntryReferenceBlockHtml
616
+ expect(arrayResult).to eq [EntryReferenceBlockHtml]
617
+ end
618
+
619
+ it 'Should return entry link embedded items' do
620
+ entry = getGQLJSONRTE(EntryReferenceLinkJson, EmbedEdges)
621
+
622
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
623
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
624
+
625
+ expect(result).to eq EntryReferenceLinkHtml
626
+ expect(arrayResult).to eq [EntryReferenceLinkHtml]
627
+ end
628
+
629
+ it 'Should return entry inline embedded items' do
630
+ entry = getGQLJSONRTE(EntryReferenceInlineJson, EmbedEdges)
631
+
632
+ result = ContentstackUtils::GQL.json_to_html(entry['single_rte'], ContentstackUtils::Model::Options.new())
633
+ arrayResult = ContentstackUtils::GQL.json_to_html(entry['multiple_rte'], ContentstackUtils::Model::Options.new())
634
+
635
+ expect(result).to eq EntryReferenceInlineHtml
636
+ expect(arrayResult).to eq [EntryReferenceInlineHtml]
637
+ end
638
+ end
639
+
640
+ def makeRenderFunction(content, option = ContentstackUtils::Model::Options.new(ENTRY_EMBEDDED_ASSET))
641
+ ContentstackUtils.render_content(content, option)
642
+ end
643
643
  end