@@ -17,21 +17,32 @@ describe('createQueries', () => {
1717 // valid type
1818 it ( 'should update type to reference correctly' , ( ) => {
1919 const queries = createQueries ( ) ;
20- const node = { value : 'This is a {string} type.' } ;
21- queries . updateTypeReference ( node ) ;
22- strictEqual ( node . type , 'html' ) ;
23- strictEqual (
24- node . value ,
25- 'This is a [`<string>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) type.'
20+ const node = {
21+ value : 'This is a {string} type.' ,
22+ position : { start : 0 , end : 0 } ,
23+ } ;
24+ const parent = { children : [ node ] } ;
25+ queries . updateTypeReference ( node , parent ) ;
26+ deepStrictEqual (
27+ parent . children . map ( c => c . value ) ,
28+ [
29+ 'This is a ' ,
30+ undefined , // link
31+ ' type.' ,
32+ ]
2633 ) ;
2734 } ) ;
2835
2936 it ( 'should update type to reference not correctly if no match' , ( ) => {
3037 const queries = createQueries ( ) ;
31- const node = { value : 'This is a {test} type.' } ;
32- queries . updateTypeReference ( node ) ;
33- strictEqual ( node . type , 'html' ) ;
34- strictEqual ( node . value , 'This is a {test} type.' ) ;
38+ const node = {
39+ value : 'This is a {test} type.' ,
40+ position : { start : 0 , end : 0 } ,
41+ } ;
42+ const parent = { children : [ node ] } ;
43+ queries . updateTypeReference ( node , parent ) ;
44+ strictEqual ( parent . children [ 0 ] . type , 'text' ) ;
45+ strictEqual ( parent . children [ 0 ] . value , 'This is a {test} type.' ) ;
3546 } ) ;
3647
3748 it ( 'should add heading metadata correctly' , ( ) => {
0 commit comments