@@ -39,7 +39,14 @@ describe('adapters', () => {
39
39
testAdapters (
40
40
'document with block' ,
41
41
contentful . document ( contentful . block ( Contentful . BLOCKS . PARAGRAPH , contentful . text ( '' ) ) ) ,
42
- slate . document ( slate . block ( Contentful . BLOCKS . PARAGRAPH , false , slate . text ( slate . leaf ( '' ) ) ) ) ,
42
+ [
43
+ {
44
+ type : Contentful . BLOCKS . PARAGRAPH ,
45
+ children : [
46
+ { text : '' }
47
+ ]
48
+ }
49
+ ] ,
43
50
) ;
44
51
45
52
testAdapters (
@@ -50,19 +57,27 @@ describe('adapters', () => {
50
57
contentful . inline ( Contentful . INLINES . HYPERLINK ) ,
51
58
) ,
52
59
) ,
53
- slate . document (
54
- slate . block (
55
- Contentful . BLOCKS . PARAGRAPH ,
56
- false ,
57
- slate . inline ( Contentful . INLINES . HYPERLINK , false ) ,
58
- ) ,
59
- ) ,
60
+ [
61
+ {
62
+ type : Contentful . BLOCKS . PARAGRAPH ,
63
+ children : [
64
+ { type : Contentful . INLINES . HYPERLINK }
65
+ ]
66
+ }
67
+ ] ,
60
68
) ;
61
69
62
70
testAdapters (
63
71
'paragraph with text' ,
64
72
contentful . document ( contentful . block ( Contentful . BLOCKS . PARAGRAPH , contentful . text ( 'hi' ) ) ) ,
65
- slate . document ( slate . block ( Contentful . BLOCKS . PARAGRAPH , false , slate . text ( slate . leaf ( 'hi' ) ) ) ) ,
73
+ [
74
+ {
75
+ type : Contentful . BLOCKS . PARAGRAPH ,
76
+ children : [
77
+ { text : 'hi' }
78
+ ]
79
+ }
80
+ ] ,
66
81
) ;
67
82
68
83
testAdapters (
@@ -74,24 +89,26 @@ describe('adapters', () => {
74
89
contentful . text ( 'is' , contentful . mark ( 'bold' ) ) ,
75
90
) ,
76
91
) ,
77
- slate . document (
78
- slate . block (
79
- Contentful . BLOCKS . PARAGRAPH ,
80
- false ,
81
- slate . text ( slate . leaf ( 'this' ) ) ,
82
- slate . text ( slate . leaf ( 'is' , slate . mark ( 'bold' ) ) ) ,
83
- ) ,
84
- ) ,
92
+ [
93
+ {
94
+ type : Contentful . BLOCKS . PARAGRAPH ,
95
+ children : [
96
+ { text : 'this' } ,
97
+ { text : 'is' , bold : true } ,
98
+ ] ,
99
+ } ,
100
+ ] ,
85
101
) ;
86
102
87
103
it ( 'adds a default value to marks if undefined' , ( ) => {
88
- const slateDoc = slate . document (
89
- slate . block (
90
- Contentful . BLOCKS . PARAGRAPH ,
91
- false ,
92
- slate . text ( { marks : undefined , object : 'leaf' , text : 'Hi' } ) ,
93
- ) ,
94
- ) ;
104
+ const slateDoc = [
105
+ {
106
+ type : Contentful . BLOCKS . PARAGRAPH ,
107
+ children : [
108
+ { text : 'Hi' }
109
+ ]
110
+ }
111
+ ] ;
95
112
const ctflDoc = toContentfulDocument ( {
96
113
document : slateDoc ,
97
114
} ) ;
@@ -117,15 +134,16 @@ describe('adapters', () => {
117
134
contentful . text ( 'huge' , contentful . mark ( 'bold' ) , contentful . mark ( 'italic' ) ) ,
118
135
) ,
119
136
) ,
120
- slate . document (
121
- slate . block (
122
- Contentful . BLOCKS . PARAGRAPH ,
123
- false ,
124
- slate . text ( slate . leaf ( 'this' ) ) ,
125
- slate . text ( slate . leaf ( 'is' , slate . mark ( 'bold' ) ) ) ,
126
- slate . text ( slate . leaf ( 'huge' , slate . mark ( 'bold' ) , slate . mark ( 'italic' ) ) ) ,
127
- ) ,
128
- ) ,
137
+ [
138
+ {
139
+ type : Contentful . BLOCKS . PARAGRAPH ,
140
+ children : [
141
+ { text : 'this' } ,
142
+ { text : 'is' , bold : true } ,
143
+ { text : 'huge' , bold : true , italic : true } ,
144
+ ] ,
145
+ } ,
146
+ ] ,
129
147
) ;
130
148
131
149
testAdapters (
@@ -134,26 +152,28 @@ describe('adapters', () => {
134
152
contentful . block (
135
153
Contentful . BLOCKS . PARAGRAPH ,
136
154
contentful . text ( 'this is a test' , contentful . mark ( 'bold' ) ) ,
137
- contentful . text ( Contentful . BLOCKS . PARAGRAPH , contentful . mark ( 'underline' ) ) ,
155
+ contentful . text ( 'paragraph' , contentful . mark ( 'underline' ) ) ,
138
156
) ,
139
157
contentful . block (
140
158
Contentful . BLOCKS . QUOTE ,
141
159
contentful . block ( Contentful . BLOCKS . PARAGRAPH , contentful . text ( 'this is it' ) ) ,
142
160
) ,
143
161
) ,
144
- slate . document (
145
- slate . block (
146
- Contentful . BLOCKS . PARAGRAPH ,
147
- false ,
148
- slate . text ( slate . leaf ( 'this is a test' , slate . mark ( 'bold' ) ) ) ,
149
- slate . text ( slate . leaf ( Contentful . BLOCKS . PARAGRAPH , slate . mark ( 'underline' ) ) ) ,
150
- ) ,
151
- slate . block (
152
- Contentful . BLOCKS . QUOTE ,
153
- false ,
154
- slate . block ( Contentful . BLOCKS . PARAGRAPH , false , slate . text ( slate . leaf ( 'this is it' ) ) ) ,
155
- ) ,
156
- ) ,
162
+ [
163
+ {
164
+ type : Contentful . BLOCKS . PARAGRAPH ,
165
+ children : [
166
+ { text : 'this is a test' , bold : true } ,
167
+ { type : 'paragraph' , underline : true } ,
168
+ ] ,
169
+ } ,
170
+ {
171
+ type : Contentful . BLOCKS . PARAGRAPH ,
172
+ children : [
173
+ { text : 'this is it' } ,
174
+ ] ,
175
+ } ,
176
+ ] ,
157
177
) ;
158
178
} ) ;
159
179
@@ -171,19 +191,12 @@ describe('adapters', () => {
171
191
} ,
172
192
] ,
173
193
} ,
174
- {
175
- object : 'document' ,
176
- data : { } ,
177
- nodes : [
178
- {
179
- object : 'block' ,
180
- type : Contentful . BLOCKS . PARAGRAPH ,
181
- isVoid : false ,
182
- data : { a : 1 } ,
183
- nodes : [ ] ,
184
- } ,
185
- ] ,
186
- } ,
194
+ [
195
+ {
196
+ type : Contentful . BLOCKS . PARAGRAPH ,
197
+ data : { a : 1 } ,
198
+ } ,
199
+ ] ,
187
200
) ;
188
201
189
202
testAdapters (
@@ -205,29 +218,18 @@ describe('adapters', () => {
205
218
} ,
206
219
] ,
207
220
} ,
208
- {
209
- object : 'document' ,
210
- data : { } ,
211
- nodes : [
212
- {
213
- object : 'block' ,
214
- type : Contentful . BLOCKS . PARAGRAPH ,
215
- isVoid : false ,
216
- data : { a : 1 } ,
217
- nodes : [
218
- {
219
- object : 'inline' ,
220
- type : Contentful . INLINES . HYPERLINK ,
221
- isVoid : false ,
222
- data : {
223
- a : 2 ,
224
- } ,
225
- nodes : [ ] ,
226
- } ,
227
- ] ,
228
- } ,
229
- ] ,
230
- } ,
221
+ [
222
+ {
223
+ type : Contentful . BLOCKS . PARAGRAPH ,
224
+ data : { a : 1 } ,
225
+ children : [
226
+ {
227
+ type : Contentful . INLINES . HYPERLINK ,
228
+ data : { a : 2 } ,
229
+ } ,
230
+ ] ,
231
+ } ,
232
+ ] ,
231
233
) ;
232
234
233
235
testAdapters (
@@ -255,40 +257,23 @@ describe('adapters', () => {
255
257
} ,
256
258
] ,
257
259
} ,
258
- {
259
- object : 'document' ,
260
- data : { } ,
261
- nodes : [
262
- {
263
- object : 'block' ,
264
- type : Contentful . BLOCKS . PARAGRAPH ,
265
- isVoid : false ,
266
- data : { a : 1 } ,
267
- nodes : [
268
- {
269
- object : 'inline' ,
270
- type : Contentful . INLINES . HYPERLINK ,
271
- isVoid : false ,
272
- data : {
273
- a : 2 ,
274
- } ,
275
- nodes : [ ] ,
276
- } ,
277
- {
278
- object : 'text' ,
279
- data : { a : 3 } ,
280
- leaves : [
281
- {
282
- object : 'leaf' ,
283
- marks : [ ] ,
284
- text : 'YO' ,
285
- } ,
286
- ] ,
287
- } ,
288
- ] ,
289
- } ,
290
- ] ,
291
- } ,
260
+ [
261
+ {
262
+ type : Contentful . BLOCKS . PARAGRAPH ,
263
+ data : { a : 1 } ,
264
+ children : [
265
+ {
266
+ type : Contentful . INLINES . HYPERLINK ,
267
+ data : { a : 2 } ,
268
+ children : [
269
+ {
270
+ text : 'YO' ,
271
+ data : { a : 3 } ,
272
+ ]
273
+ } ,
274
+ ] ,
275
+ } ,
276
+ ] ,
292
277
) ;
293
278
} ) ;
294
279
@@ -306,20 +291,15 @@ describe('adapters', () => {
306
291
} ,
307
292
] ,
308
293
} ,
309
- {
310
- object : 'document' ,
311
- data : { } ,
312
- nodes : [
313
- {
314
- object : 'block' ,
315
- type : Contentful . BLOCKS . EMBEDDED_ENTRY ,
316
- isVoid : true ,
317
- data : { a : 1 } ,
318
- nodes : [ ] ,
319
- } ,
320
- ] ,
321
- } ,
294
+ [
295
+ {
296
+ type : Contentful . BLOCKS . EMBEDDED_ENTRY ,
297
+ data : { a : 1 } ,
298
+ isVoid : true ,
299
+ } ,
300
+ ] ,
322
301
) ;
302
+
323
303
test ( 'removes empty text nodes from void nodes content' , ( ) => {
324
304
const contentfulDoc : Contentful . Document = {
325
305
nodeType : Contentful . BLOCKS . DOCUMENT ,
@@ -333,32 +313,16 @@ describe('adapters', () => {
333
313
] ,
334
314
} ;
335
315
336
- const slateDoc : Slate . Document = {
337
- object : 'document' ,
338
- type : 'document' ,
339
- data : { } ,
340
- nodes : [
341
- {
342
- object : 'block' ,
343
- type : Contentful . BLOCKS . EMBEDDED_ENTRY ,
344
- isVoid : true ,
345
- data : { a : 1 } ,
346
- nodes : [
347
- {
348
- object : 'text' ,
349
- data : { } ,
350
- leaves : [
351
- {
352
- object : 'leaf' ,
353
- marks : [ ] ,
354
- text : '' ,
355
- } ,
356
- ] ,
357
- } ,
358
- ] ,
359
- } ,
360
- ] ,
361
- } ;
316
+ const slateDoc : Slate . Document = [
317
+ {
318
+ type : Contentful . BLOCKS . EMBEDDED_ENTRY ,
319
+ data : { a : 1 } ,
320
+ isVoid : true ,
321
+ children : [
322
+ { text : '' } ,
323
+ ]
324
+ } ,
325
+ ] ;
362
326
363
327
const actualContentfulDoc = toContentfulDocument ( {
364
328
document : slateDoc ,
0 commit comments