@@ -15,23 +15,34 @@ describe('createQueries', () => {
15
15
} ) ;
16
16
17
17
// valid type
18
- it ( 'should update type to reference correctly' , ( ) => {
18
+ it . only ( 'should update type to reference correctly' , ( ) => {
19
19
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
+ ]
26
33
) ;
27
34
} ) ;
28
35
29
36
it ( 'should update type to reference not correctly if no match' , ( ) => {
30
37
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.' ) ;
35
46
} ) ;
36
47
37
48
it ( 'should add heading metadata correctly' , ( ) => {
0 commit comments