contentstack_utils 0.1.0.pre.beta.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module ContentstackUtils
2
- VERSION = "0.1.0-beta.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -51,5 +51,45 @@ RSpec.describe ContentstackUtils::Model::Metadata do
51
51
  expect(metadata.text).to eq 'TEST'
52
52
  end
53
53
  end
54
+
55
+ it 'Asset Json To metadata' do
56
+ doc = getJson(AssetReferenceJson)
57
+ metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
58
+ expect(metadata.item_type).to eq "asset"
59
+ expect(metadata.style_type).to eq "display"
60
+ expect(metadata.item_uid).to eq "blt44asset"
61
+ expect(metadata.content_type_uid).to eq 'sys_assets'
62
+ expect(metadata.text).to eq ''
63
+ end
64
+
65
+ it 'Entry Block Json To metadata' do
66
+ doc = getJson(EntryReferenceBlockJson)
67
+ metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
68
+ expect(metadata.item_type).to eq "entry"
69
+ expect(metadata.style_type).to eq "block"
70
+ expect(metadata.item_uid).to eq "blttitleuid"
71
+ expect(metadata.content_type_uid).to eq 'content_block'
72
+ expect(metadata.text).to eq ''
73
+ end
74
+
75
+ it 'Entry Link Json To metadata' do
76
+ doc = getJson(EntryReferenceLinkJson)
77
+ metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
78
+ expect(metadata.item_type).to eq "entry"
79
+ expect(metadata.style_type).to eq "link"
80
+ expect(metadata.item_uid).to eq "bltemmbedEntryuid"
81
+ expect(metadata.content_type_uid).to eq 'embeddedrte'
82
+ expect(metadata.text).to eq "/copy-of-entry-final-02"
83
+ end
84
+
85
+ it 'Entry Inline Json To metadata' do
86
+ doc = getJson(EntryReferenceInlineJson)
87
+ metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
88
+ expect(metadata.item_type).to eq "entry"
89
+ expect(metadata.style_type).to eq "inline"
90
+ expect(metadata.item_uid).to eq "blttitleUpdateuid"
91
+ expect(metadata.content_type_uid).to eq 'embeddedrte'
92
+ expect(metadata.text).to eq ''
93
+ end
54
94
  end
55
95
  end
@@ -82,5 +82,221 @@ RSpec.describe ContentstackUtils::Model::Options do
82
82
  expect(subject.render_option(ASSET_CONTENT_URL, getMetadata('entry', 'download', linkText))).
83
83
  to eq "<a href='url'>#{linkText}</a>"
84
84
  end
85
+
86
+ it 'Should return Mark text html' do
87
+ expect(subject.render_mark('bold', linkText)).
88
+ to eq "<strong>#{linkText}</strong>"
89
+ expect(subject.render_mark('italic', linkText)).
90
+ to eq "<em>#{linkText}</em>"
91
+ expect(subject.render_mark('underline', linkText)).
92
+ to eq "<u>#{linkText}</u>"
93
+ expect(subject.render_mark('strikethrough', linkText)).
94
+ to eq "<strike>#{linkText}</strike>"
95
+ expect(subject.render_mark('inlineCode', linkText)).
96
+ to eq "<span>#{linkText}</span>"
97
+ expect(subject.render_mark('subscript', linkText)).
98
+ to eq "<sub>#{linkText}</sub>"
99
+ expect(subject.render_mark('superscript', linkText)).
100
+ to eq "<sup>#{linkText}</sup>"
101
+ expect(subject.render_mark('', linkText)).
102
+ to eq linkText
103
+ end
104
+
105
+ it 'Should return blank string for doc node type' do
106
+ doc = getJson(BlankDocument)
107
+
108
+ result = subject.render_node('doc', doc, linkText)
109
+ expect(result).to eq ""
110
+ end
111
+
112
+ it 'Should return paragraph string for paragrpah node type' do
113
+ doc = getJson(BlankDocument)
114
+
115
+ result = subject.render_node('p', doc, linkText)
116
+ expect(result).to eq "<p>#{linkText}</p>"
117
+ end
118
+
119
+ it 'Should return link string with blank href for link node type' do
120
+ doc = getJson(BlankDocument)
121
+
122
+ result = subject.render_node('a', doc, linkText)
123
+ expect(result).to eq "<a href=''>#{linkText}</a>"
124
+ end
125
+
126
+ it 'Should return link string for link node type' do
127
+ doc = getJson(LinkInPJson)["children"][0]
128
+
129
+ result = subject.render_node('a', doc, linkText)
130
+ expect(result).to eq "<a href='#{doc["attrs"]["href"]}'>#{linkText}</a>"
131
+ end
132
+
133
+ it 'Should return image string with blank src for image node type' do
134
+ doc = getJson(BlankDocument)
135
+
136
+ result = subject.render_node('img', doc, linkText)
137
+ expect(result).to eq "<img src='' />#{linkText}"
138
+ end
139
+
140
+ it 'Should return link string for link node type' do
141
+ doc = getJson(ImgJson)["children"][0]
142
+
143
+ result = subject.render_node('img', doc, linkText)
144
+ expect(result).to eq "<img src='#{doc["attrs"]["src"]}' />#{linkText}"
145
+ end
146
+
147
+ it 'Should return embed string with blank src for embed node type' do
148
+ doc = getJson(BlankDocument)
149
+
150
+ result = subject.render_node('embed', doc, linkText)
151
+ expect(result).to eq "<iframe src=''></iframe>"
152
+ end
153
+
154
+ it 'Should return embed string for embed node type' do
155
+ doc = getJson(EmbedJson)["children"][0]
156
+
157
+ result = subject.render_node('embed', doc, linkText)
158
+ expect(result).to eq "<iframe src='#{doc["attrs"]["src"]}'></iframe>"
159
+ end
160
+
161
+ it 'Should return Heading 1 string for Heading 1 node type' do
162
+ doc = getJson(BlankDocument)
163
+
164
+ result = subject.render_node('h1', doc, linkText)
165
+ expect(result).to eq "<h1>#{linkText}</h1>"
166
+ end
167
+
168
+ it 'Should return Heading 2 string for Heading 2 node type' do
169
+ doc = getJson(BlankDocument)
170
+
171
+ result = subject.render_node('h2', doc, linkText)
172
+ expect(result).to eq "<h2>#{linkText}</h2>"
173
+ end
174
+
175
+ it 'Should return Heading 3 string for Heading 3 node type' do
176
+ doc = getJson(BlankDocument)
177
+
178
+ result = subject.render_node('h3', doc, linkText)
179
+ expect(result).to eq "<h3>#{linkText}</h3>"
180
+ end
181
+
182
+ it 'Should return Heading 4 string for Heading 4 node type' do
183
+ doc = getJson(BlankDocument)
184
+
185
+ result = subject.render_node('h4', doc, linkText)
186
+ expect(result).to eq "<h4>#{linkText}</h4>"
187
+ end
188
+
189
+ it 'Should return Heading 5 string for Heading 5 node type' do
190
+ doc = getJson(BlankDocument)
191
+
192
+ result = subject.render_node('h5', doc, linkText)
193
+ expect(result).to eq "<h5>#{linkText}</h5>"
194
+ end
195
+
196
+ it 'Should return Heading 6 string for Heading 6 node type' do
197
+ doc = getJson(BlankDocument)
198
+
199
+ result = subject.render_node('h6', doc, linkText)
200
+ expect(result).to eq "<h6>#{linkText}</h6>"
201
+ end
202
+
203
+ it 'Should return Hr string for Hr node type' do
204
+ doc = getJson(BlankDocument)
205
+
206
+ result = subject.render_node('hr', doc, linkText)
207
+ expect(result).to eq "<hr />"
208
+ end
209
+
210
+ it 'Should return order list string for order list node type' do
211
+ doc = getJson(BlankDocument)
212
+
213
+ result = subject.render_node('ol', doc, linkText)
214
+ expect(result).to eq "<ol>#{linkText}</ol>"
215
+ end
216
+
217
+ it 'Should return Unorder list string for Unorder list node type' do
218
+ doc = getJson(BlankDocument)
219
+
220
+ result = subject.render_node('ul', doc, linkText)
221
+ expect(result).to eq "<ul>#{linkText}</ul>"
222
+ end
223
+
224
+ it 'Should return list item string for list item node type' do
225
+ doc = getJson(BlankDocument)
226
+
227
+ result = subject.render_node('li', doc, linkText)
228
+ expect(result).to eq "<li>#{linkText}</li>"
229
+ end
230
+
231
+ it 'Should return table string for table node type' do
232
+ doc = getJson(BlankDocument)
233
+
234
+ result = subject.render_node('table', doc, linkText)
235
+ expect(result).to eq "<table>#{linkText}</table>"
236
+ end
237
+
238
+ it 'Should return thead string for thead node type' do
239
+ doc = getJson(BlankDocument)
240
+
241
+ result = subject.render_node('thead', doc, linkText)
242
+ expect(result).to eq "<thead>#{linkText}</thead>"
243
+ end
244
+
245
+ it 'Should return tfoot string for tfoot node type' do
246
+ doc = getJson(BlankDocument)
247
+
248
+ result = subject.render_node('tfoot', doc, linkText)
249
+ expect(result).to eq "<tfoot>#{linkText}</tfoot>"
250
+ end
251
+
252
+ it 'Should return tbody string fortbody node type' do
253
+ doc = getJson(BlankDocument)
254
+
255
+ result = subject.render_node('tbody', doc, linkText)
256
+ expect(result).to eq "<tbody>#{linkText}</tbody>"
257
+ end
258
+
259
+ it 'Should return table row string for table row node type' do
260
+ doc = getJson(BlankDocument)
261
+
262
+ result = subject.render_node('tr', doc, linkText)
263
+ expect(result).to eq "<tr>#{linkText}</tr>"
264
+ end
265
+
266
+ it 'Should return table head string for table head node type' do
267
+ doc = getJson(BlankDocument)
268
+
269
+ result = subject.render_node('th', doc, linkText)
270
+ expect(result).to eq "<th>#{linkText}</th>"
271
+ end
272
+
273
+ it 'Should return table data string for table data node type' do
274
+ doc = getJson(BlankDocument)
275
+
276
+ result = subject.render_node('td', doc, linkText)
277
+ expect(result).to eq "<td>#{linkText}</td>"
278
+ end
279
+
280
+ it 'Should return blockquote string for blockquote node type' do
281
+ doc = getJson(BlankDocument)
282
+
283
+ result = subject.render_node('blockquote', doc, linkText)
284
+ expect(result).to eq "<blockquote>#{linkText}</blockquote>"
285
+ end
286
+
287
+ it 'Should return code string for code node type' do
288
+ doc = getJson(BlankDocument)
289
+
290
+ result = subject.render_node('code', doc, linkText)
291
+ expect(result).to eq "<code>#{linkText}</code>"
292
+ end
293
+
294
+ it 'Should return blank string for reference node type' do
295
+ doc = getJson(BlankDocument)
296
+
297
+ result = subject.render_node('reference', doc, linkText)
298
+ expect(result).to eq ""
299
+ end
300
+
85
301
  end
86
302
  end
@@ -59,6 +59,584 @@ RSpec.describe ContentstackUtils do
59
59
  end
60
60
  end
61
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
+
62
640
  def makeRenderFunction(content, option = ContentstackUtils::Model::Options.new(ENTRY_EMBEDDED_ASSET))
63
641
  ContentstackUtils.render_content(content, option)
64
642
  end