@@ -33,6 +33,61 @@ describe('QUERIES', () => {
3333 strictEqual ( QUERIES . standardYamlFrontmatter . test ( content ) , false ) ;
3434 } ) ;
3535 } ) ;
36+
37+ describe ( 'normalizeTypes' , ( ) => {
38+ it ( 'matches basic types' , ( ) => {
39+ const content = '{string}' ;
40+ QUERIES . normalizeTypes . lastIndex = 0 ;
41+ ok ( QUERIES . normalizeTypes . test ( content ) ) ;
42+ } ) ;
43+
44+ it ( 'matches complex types with generics' , ( ) => {
45+ const content1 = '{Readonly<object>}' ;
46+ const content2 = '{Map<string, "ignore"|null>}' ;
47+
48+ QUERIES . normalizeTypes . lastIndex = 0 ;
49+ ok (
50+ QUERIES . normalizeTypes . test ( content1 ) ,
51+ 'Should match Readonly<object>'
52+ ) ;
53+ QUERIES . normalizeTypes . lastIndex = 0 ;
54+ ok ( QUERIES . normalizeTypes . test ( content2 ) , 'Should match Map<...>' ) ;
55+ } ) ;
56+
57+ it ( 'matches complex union types with parentheses' , ( ) => {
58+ const content = '{(string|number)}' ;
59+ QUERIES . normalizeTypes . lastIndex = 0 ;
60+ ok (
61+ QUERIES . normalizeTypes . test ( content ) ,
62+ 'Should match union with parentheses'
63+ ) ;
64+ } ) ;
65+ } ) ;
66+
67+ describe ( 'linksWithTypes' , ( ) => {
68+ it ( 'matches basic type links' , ( ) => {
69+ const content = '[`<string>`](https://mdn...)' ;
70+ QUERIES . linksWithTypes . lastIndex = 0 ;
71+ ok ( QUERIES . linksWithTypes . test ( content ) ) ;
72+ } ) ;
73+
74+ it ( 'matches complex type links with generics' , ( ) => {
75+ const content1 =
76+ '[`<Readonly>`](https://mdn...)<[`<object>`](https://mdn...)>' ;
77+ QUERIES . linksWithTypes . lastIndex = 0 ;
78+ ok (
79+ QUERIES . linksWithTypes . test ( content1 ) ,
80+ 'Should match generic type link'
81+ ) ;
82+ } ) ;
83+
84+ it ( 'matches complex type links with unions' , ( ) => {
85+ const content2 =
86+ '<([`<string>`](https://mdn...)|[`<number>`](https://mdn...))>' ;
87+ QUERIES . linksWithTypes . lastIndex = 0 ;
88+ ok ( QUERIES . linksWithTypes . test ( content2 ) , 'Should match union type link' ) ;
89+ } ) ;
90+ } ) ;
3691} ) ;
3792
3893describe ( 'UNIST' , ( ) => {
0 commit comments