@@ -65,6 +65,14 @@ describe('block-component', () => {
6565 } ,
6666 'jsonScapeAttr' : {
6767 markdown : '::foo{:test=\'{"foo":"I\\\'d love to"}\'}\n::' ,
68+ expected : [
69+ '::foo' ,
70+ '---' ,
71+ 'test:' ,
72+ ' foo: I\'d love to' ,
73+ '---' ,
74+ '::' ,
75+ ] . join ( '\n' ) ,
6876 extra : ( _md , ast ) => {
6977 expect ( ast . children [ 0 ] . type ) . toBe ( 'containerComponent' )
7078 } ,
@@ -271,36 +279,78 @@ describe('block-component', () => {
271279 } ,
272280 'component-attributes-array-of-string' : {
273281 markdown : '::container-component{:items=\'["Nuxt", "Vue"]\'}\n::' ,
274- // expected: '::container-component{:items="["Nuxt", "Vue"]"}\n::',
282+ expected : [
283+ '::container-component' ,
284+ '---' ,
285+ 'items:' ,
286+ ' - Nuxt' ,
287+ ' - Vue' ,
288+ '---' ,
289+ '::' ,
290+ ] . join ( '\n' ) ,
275291 extra ( _ , ast ) {
276292 expect ( ast . children [ 0 ] . attributes ) . toEqual ( { ':items' : '["Nuxt", "Vue"]' } )
277293 expect ( ast . children [ 0 ] . data . hProperties ) . toEqual ( { ':items' : '["Nuxt", "Vue"]' } )
278294 } ,
279295 } ,
280296 'component-attributes-bad-array' : {
281297 markdown : '::container-component{:items="[Nuxt,Vue]"}\n::' ,
298+ expected : [
299+ '::container-component' ,
300+ '---' ,
301+ ':items: "[Nuxt,Vue]"' ,
302+ '---' ,
303+ '::' ,
304+ ] . join ( '\n' ) ,
282305 extra ( _ , ast ) {
283306 expect ( ast . children [ 0 ] . attributes ) . toEqual ( { ':items' : '[Nuxt,Vue]' } )
284307 expect ( ast . children [ 0 ] . data . hProperties ) . toEqual ( { ':items' : '[Nuxt,Vue]' } )
285308 } ,
286309 } ,
287310 'component-attributes-array-of-number' : {
288311 markdown : '::container-component{:items=\'[1,2,3.5]\'}\n::' ,
312+ expected : [
313+ '::container-component' ,
314+ '---' ,
315+ 'items:' ,
316+ ' - 1' ,
317+ ' - 2' ,
318+ ' - 3.5' ,
319+ '---' ,
320+ '::' ,
321+ ] . join ( '\n' ) ,
289322 extra ( _ , ast ) {
290323 expect ( ast . children [ 0 ] . attributes ) . toEqual ( { ':items' : '[1,2,3.5]' } )
291324 expect ( ast . children [ 0 ] . data . hProperties ) . toEqual ( { ':items' : '[1,2,3.5]' } )
292325 } ,
293326 } ,
294327 'component-attributes-array-convert-double-quote' : {
295328 markdown : '::container-component{:items="[1,2,3.5]"}\n::' ,
296- expected : '::container-component{:items=\'[1,2,3.5]\'}\n::' ,
329+ expected : [
330+ '::container-component' ,
331+ '---' ,
332+ 'items:' ,
333+ ' - 1' ,
334+ ' - 2' ,
335+ ' - 3.5' ,
336+ '---' ,
337+ '::' ,
338+ ] . join ( '\n' ) ,
297339 extra ( _ , ast ) {
298340 expect ( ast . children [ 0 ] . attributes ) . toEqual ( { ':items' : '[1,2,3.5]' } )
299341 expect ( ast . children [ 0 ] . data . hProperties ) . toEqual ( { ':items' : '[1,2,3.5]' } )
300342 } ,
301343 } ,
302344 'component-attributes-object' : {
303345 markdown : '::container-component{:items=\'{"key": "value"}\'}\n::' ,
346+ expected : [
347+ '::container-component' ,
348+ '---' ,
349+ 'items:' ,
350+ ' key: value' ,
351+ '---' ,
352+ '::' ,
353+ ] . join ( '\n' ) ,
304354 extra ( _ , ast ) {
305355 expect ( ast . children [ 0 ] . attributes ) . toEqual ( { ':items' : '{"key": "value"}' } )
306356 expect ( ast . children [ 0 ] . data . hProperties ) . toEqual ( { ':items' : '{"key": "value"}' } )
@@ -317,6 +367,21 @@ describe('block-component', () => {
317367 '---' ,
318368 '::' ,
319369 ] . join ( '\n' ) ,
370+ expected : [
371+ '::container-component' ,
372+ '---' ,
373+ 'items:' ,
374+ ' key: value' ,
375+ '---' ,
376+ '::' ,
377+ '' ,
378+ '::container-component' ,
379+ '---' ,
380+ 'items:' ,
381+ ' key: value' ,
382+ '---' ,
383+ '::' ,
384+ ] . join ( '\n' ) ,
320385 extra ( _ , ast ) {
321386 expect ( ast . children [ 0 ] . attributes ) . toEqual ( { ':items' : '{"key":"value"}' } )
322387 expect ( ast . children [ 1 ] . attributes ) . toEqual ( { } )
0 commit comments