@@ -25,50 +25,64 @@ const defaultMagicComments: MagicCommentConfig[] = [
2525describe ( 'parseCodeBlockMetaOptions' , ( ) => {
2626 describe ( 'title' , ( ) => {
2727 it ( 'parses double quote delimited title' , ( ) => {
28- expect ( parseCodeBlockMetaOptions ( `title="index.js"` ) . title ) . toBe (
29- ` index.js` ,
30- ) ;
28+ expect (
29+ parseCodeBlockMetaOptions ( `title=" index.js"` , undefined ) . title ,
30+ ) . toBe ( `index.js` ) ;
3131 } ) ;
3232
3333 it ( 'parses single quote delimited title' , ( ) => {
34- expect ( parseCodeBlockMetaOptions ( `title='index.js'` ) . title ) . toBe (
35- ` index.js` ,
36- ) ;
34+ expect (
35+ parseCodeBlockMetaOptions ( `title=' index.js'` , undefined ) . title ,
36+ ) . toBe ( `index.js` ) ;
3737 } ) ;
3838
3939 it ( 'does not parse mismatched quote delimiters' , ( ) => {
40- expect ( parseCodeBlockMetaOptions ( `title="index.js'` ) . title ) . toBe ( `` ) ;
40+ expect (
41+ parseCodeBlockMetaOptions ( `title="index.js'` , undefined ) . title ,
42+ ) . toBe ( `` ) ;
4143 } ) ;
4244
4345 it ( 'parses undefined metastring' , ( ) => {
44- expect ( parseCodeBlockMetaOptions ( undefined ) . title ) . toBe ( `` ) ;
46+ expect ( parseCodeBlockMetaOptions ( undefined , undefined ) . title ) . toBe ( `` ) ;
4547 } ) ;
4648
4749 it ( 'parses metastring with no title specified' , ( ) => {
48- expect ( parseCodeBlockMetaOptions ( `{1,2-3}` ) . title ) . toBe ( `` ) ;
50+ expect ( parseCodeBlockMetaOptions ( `{1,2-3}` , undefined ) . title ) . toBe ( `` ) ;
4951 } ) ;
5052
5153 it ( 'parses with multiple metadata title first' , ( ) => {
5254 expect (
53- parseCodeBlockMetaOptions ( `title="index.js" label="JavaScript"` ) . title ,
55+ parseCodeBlockMetaOptions (
56+ `title="index.js" label="JavaScript"` ,
57+ undefined ,
58+ ) . title ,
5459 ) . toBe ( `index.js` ) ;
5560 } ) ;
5661
5762 it ( 'parses with multiple metadata title last' , ( ) => {
5863 expect (
59- parseCodeBlockMetaOptions ( `label="JavaScript" title="index.js"` ) . title ,
64+ parseCodeBlockMetaOptions (
65+ `label="JavaScript" title="index.js"` ,
66+ undefined ,
67+ ) . title ,
6068 ) . toBe ( `index.js` ) ;
6169 } ) ;
6270
6371 it ( 'parses double quotes when delimited by single quotes' , ( ) => {
6472 expect (
65- parseCodeBlockMetaOptions ( `title='console.log("Hello, World!")'` ) . title ,
73+ parseCodeBlockMetaOptions (
74+ `title='console.log("Hello, World!")'` ,
75+ undefined ,
76+ ) . title ,
6677 ) . toBe ( `console.log("Hello, World!")` ) ;
6778 } ) ;
6879
6980 it ( 'parses single quotes when delimited by double quotes' , ( ) => {
7081 expect (
71- parseCodeBlockMetaOptions ( `title="console.log('Hello, World!')"` ) . title ,
82+ parseCodeBlockMetaOptions (
83+ `title="console.log('Hello, World!')"` ,
84+ undefined ,
85+ ) . title ,
7286 ) . toBe ( `console.log('Hello, World!')` ) ;
7387 } ) ;
7488 } ) ;
@@ -148,7 +162,11 @@ bbbbb`,
148162 `// highlight-next-line
149163aaaaa
150164bbbbb` ,
151- { metastring : '' , language : 'js' , magicComments : defaultMagicComments } ,
165+ {
166+ metastring : '' ,
167+ language : 'js' ,
168+ magicComments : defaultMagicComments ,
169+ } ,
152170 ) ,
153171 ) . toMatchSnapshot ( ) ;
154172 expect (
@@ -157,7 +175,11 @@ bbbbb`,
157175aaaaa
158176// highlight-end
159177bbbbb` ,
160- { metastring : '' , language : 'js' , magicComments : defaultMagicComments } ,
178+ {
179+ metastring : '' ,
180+ language : 'js' ,
181+ magicComments : defaultMagicComments ,
182+ } ,
161183 ) ,
162184 ) . toMatchSnapshot ( ) ;
163185 expect (
@@ -169,7 +191,11 @@ bbbbbbb
169191// highlight-next-line
170192// highlight-end
171193bbbbb` ,
172- { metastring : '' , language : 'js' , magicComments : defaultMagicComments } ,
194+ {
195+ metastring : '' ,
196+ language : 'js' ,
197+ magicComments : defaultMagicComments ,
198+ } ,
173199 ) ,
174200 ) . toMatchSnapshot ( ) ;
175201 } ) ;
@@ -179,15 +205,23 @@ bbbbb`,
179205 `# highlight-next-line
180206aaaaa
181207bbbbb` ,
182- { metastring : '' , language : 'js' , magicComments : defaultMagicComments } ,
208+ {
209+ metastring : '' ,
210+ language : 'js' ,
211+ magicComments : defaultMagicComments ,
212+ } ,
183213 ) ,
184214 ) . toMatchSnapshot ( 'js' ) ;
185215 expect (
186216 parseLines (
187217 `/* highlight-next-line */
188218aaaaa
189219bbbbb` ,
190- { metastring : '' , language : 'py' , magicComments : defaultMagicComments } ,
220+ {
221+ metastring : '' ,
222+ language : 'py' ,
223+ magicComments : defaultMagicComments ,
224+ } ,
191225 ) ,
192226 ) . toMatchSnapshot ( 'py' ) ;
193227 expect (
@@ -200,7 +234,11 @@ bbbbb
200234ccccc
201235<!-- highlight-next-line -->
202236dddd` ,
203- { metastring : '' , language : 'py' , magicComments : defaultMagicComments } ,
237+ {
238+ metastring : '' ,
239+ language : 'py' ,
240+ magicComments : defaultMagicComments ,
241+ } ,
204242 ) ,
205243 ) . toMatchSnapshot ( 'py' ) ;
206244 expect (
@@ -213,7 +251,11 @@ bbbbb
213251ccccc
214252<!-- highlight-next-line -->
215253dddd` ,
216- { metastring : '' , language : '' , magicComments : defaultMagicComments } ,
254+ {
255+ metastring : '' ,
256+ language : '' ,
257+ magicComments : defaultMagicComments ,
258+ } ,
217259 ) ,
218260 ) . toMatchSnapshot ( 'none' ) ;
219261 expect (
@@ -224,7 +266,11 @@ aaaa
224266bbbbb
225267<!-- highlight-next-line -->
226268dddd` ,
227- { metastring : '' , language : 'jsx' , magicComments : defaultMagicComments } ,
269+ {
270+ metastring : '' ,
271+ language : 'jsx' ,
272+ magicComments : defaultMagicComments ,
273+ } ,
228274 ) ,
229275 ) . toMatchSnapshot ( 'jsx' ) ;
230276 expect (
@@ -235,7 +281,11 @@ aaaa
235281bbbbb
236282<!-- highlight-next-line -->
237283dddd` ,
238- { metastring : '' , language : 'html' , magicComments : defaultMagicComments } ,
284+ {
285+ metastring : '' ,
286+ language : 'html' ,
287+ magicComments : defaultMagicComments ,
288+ } ,
239289 ) ,
240290 ) . toMatchSnapshot ( 'html' ) ;
241291 expect (
@@ -261,7 +311,11 @@ dddd
261311console.log("preserved");
262312\`\`\`
263313` ,
264- { metastring : '' , language : 'md' , magicComments : defaultMagicComments } ,
314+ {
315+ metastring : '' ,
316+ language : 'md' ,
317+ magicComments : defaultMagicComments ,
318+ } ,
265319 ) ,
266320 ) . toMatchSnapshot ( 'md' ) ;
267321 } ) ;
@@ -373,24 +427,26 @@ describe('getLineNumbersStart', () => {
373427 expect (
374428 getLineNumbersStart ( {
375429 showLineNumbers : undefined ,
376- metastring : undefined ,
430+ metaOptions : { } ,
377431 } ) ,
378432 ) . toMatchSnapshot ( ) ;
379433 expect (
380434 getLineNumbersStart ( {
381435 showLineNumbers : undefined ,
382- metastring : '' ,
436+ metaOptions : { } ,
383437 } ) ,
384438 ) . toMatchSnapshot ( ) ;
385439 } ) ;
386440
387441 describe ( 'handles prop' , ( ) => {
388- describe ( 'combined with metastring ' , ( ) => {
442+ describe ( 'combined with metaoptions ' , ( ) => {
389443 it ( 'set to true' , ( ) => {
390444 expect (
391445 getLineNumbersStart ( {
392446 showLineNumbers : true ,
393- metastring : 'showLineNumbers=2' ,
447+ metaOptions : {
448+ showLineNumbers : 2 ,
449+ } ,
394450 } ) ,
395451 ) . toMatchSnapshot ( ) ;
396452 } ) ;
@@ -399,7 +455,9 @@ describe('getLineNumbersStart', () => {
399455 expect (
400456 getLineNumbersStart ( {
401457 showLineNumbers : false ,
402- metastring : 'showLineNumbers=2' ,
458+ metaOptions : {
459+ showLineNumbers : 2 ,
460+ } ,
403461 } ) ,
404462 ) . toMatchSnapshot ( ) ;
405463 } ) ;
@@ -408,7 +466,9 @@ describe('getLineNumbersStart', () => {
408466 expect (
409467 getLineNumbersStart ( {
410468 showLineNumbers : 10 ,
411- metastring : 'showLineNumbers=2' ,
469+ metaOptions : {
470+ showLineNumbers : 2 ,
471+ } ,
412472 } ) ,
413473 ) . toMatchSnapshot ( ) ;
414474 } ) ;
@@ -419,7 +479,9 @@ describe('getLineNumbersStart', () => {
419479 expect (
420480 getLineNumbersStart ( {
421481 showLineNumbers : true ,
422- metastring : undefined ,
482+ metaOptions : {
483+ showLineNumbers : 2 ,
484+ } ,
423485 } ) ,
424486 ) . toMatchSnapshot ( ) ;
425487 } ) ;
@@ -428,7 +490,9 @@ describe('getLineNumbersStart', () => {
428490 expect (
429491 getLineNumbersStart ( {
430492 showLineNumbers : false ,
431- metastring : undefined ,
493+ metaOptions : {
494+ showLineNumbers : 2 ,
495+ } ,
432496 } ) ,
433497 ) . toMatchSnapshot ( ) ;
434498 } ) ;
@@ -437,7 +501,9 @@ describe('getLineNumbersStart', () => {
437501 expect (
438502 getLineNumbersStart ( {
439503 showLineNumbers : 10 ,
440- metastring : undefined ,
504+ metaOptions : {
505+ showLineNumbers : 2 ,
506+ } ,
441507 } ) ,
442508 ) . toMatchSnapshot ( ) ;
443509 } ) ;
@@ -450,15 +516,19 @@ describe('getLineNumbersStart', () => {
450516 expect (
451517 getLineNumbersStart ( {
452518 showLineNumbers : undefined ,
453- metastring : 'showLineNumbers' ,
519+ metaOptions : {
520+ showLineNumbers : true ,
521+ } ,
454522 } ) ,
455523 ) . toMatchSnapshot ( ) ;
456524 } ) ;
457525 it ( 'set with number' , ( ) => {
458526 expect (
459527 getLineNumbersStart ( {
460528 showLineNumbers : undefined ,
461- metastring : 'showLineNumbers=10' ,
529+ metaOptions : {
530+ showLineNumbers : 10 ,
531+ } ,
462532 } ) ,
463533 ) . toMatchSnapshot ( ) ;
464534 } ) ;
@@ -469,15 +539,23 @@ describe('getLineNumbersStart', () => {
469539 expect (
470540 getLineNumbersStart ( {
471541 showLineNumbers : undefined ,
472- metastring : '{1,2-3} title="file.txt" showLineNumbers noInline' ,
542+ metaOptions : {
543+ title : 'file.txt' ,
544+ showLineNumbers : true ,
545+ noInline : true ,
546+ } ,
473547 } ) ,
474548 ) . toMatchSnapshot ( ) ;
475549 } ) ;
476550 it ( 'set with number' , ( ) => {
477551 expect (
478552 getLineNumbersStart ( {
479553 showLineNumbers : undefined ,
480- metastring : '{1,2-3} title="file.txt" showLineNumbers=10 noInline' ,
554+ metaOptions : {
555+ title : 'file.txt' ,
556+ showLineNumbers : 10 ,
557+ noInline : true ,
558+ } ,
481559 } ) ,
482560 ) . toMatchSnapshot ( ) ;
483561 } ) ;
0 commit comments