@@ -110,4 +110,114 @@ describe('createQueries', () => {
110110 } ;
111111 queries . addStabilityMetadata ( node , apiEntryMetadata ) ;
112112 } ) ;
113+
114+ describe ( 'UNIST' , ( ) => {
115+ describe ( 'isTypedList' , ( ) => {
116+ it ( 'returns false for non-list nodes' , ( ) => {
117+ strictEqual (
118+ createQueries . UNIST . isTypedList ( { type : 'paragraph' , children : [ ] } ) ,
119+ false
120+ ) ;
121+ } ) ;
122+
123+ it ( 'returns false for empty lists' , ( ) => {
124+ strictEqual (
125+ createQueries . UNIST . isTypedList ( { type : 'list' , children : [ ] } ) ,
126+ false
127+ ) ;
128+ } ) ;
129+
130+ const cases = [
131+ {
132+ name : 'typedListStarters pattern match' ,
133+ node : {
134+ type : 'list' ,
135+ children : [
136+ {
137+ children : [
138+ {
139+ children : [ { type : 'text' , value : 'Returns: foo' } ] ,
140+ } ,
141+ ] ,
142+ } ,
143+ ] ,
144+ } ,
145+ expected : true ,
146+ } ,
147+ {
148+ name : 'direct type link pattern' ,
149+ node : {
150+ type : 'list' ,
151+ children : [
152+ {
153+ children : [
154+ {
155+ children : [
156+ {
157+ type : 'link' ,
158+ children : [ { type : 'inlineCode' , value : '<Type>' } ] ,
159+ } ,
160+ ] ,
161+ } ,
162+ ] ,
163+ } ,
164+ ] ,
165+ } ,
166+ expected : true ,
167+ } ,
168+ {
169+ name : 'inlineCode + space + type link pattern' ,
170+ node : {
171+ type : 'list' ,
172+ children : [
173+ {
174+ children : [
175+ {
176+ children : [
177+ { type : 'inlineCode' , value : 'foo' } ,
178+ { type : 'text' , value : ' ' } ,
179+ {
180+ type : 'link' ,
181+ children : [ { type : 'text' , value : '<Bar>' } ] ,
182+ } ,
183+ ] ,
184+ } ,
185+ ] ,
186+ } ,
187+ ] ,
188+ } ,
189+ expected : true ,
190+ } ,
191+ {
192+ name : 'non-matching content' ,
193+ node : {
194+ type : 'list' ,
195+ children : [
196+ {
197+ children : [
198+ {
199+ children : [
200+ { type : 'inlineCode' , value : 'not a valid prop' } ,
201+ { type : 'text' , value : ' ' } ,
202+ {
203+ type : 'link' ,
204+ children : [ { type : 'text' , value : '<Bar>' } ] ,
205+ } ,
206+ ] ,
207+ } ,
208+ ] ,
209+ } ,
210+ ] ,
211+ } ,
212+ expected : false ,
213+ } ,
214+ ] ;
215+
216+ cases . forEach ( ( { name, node, expected } ) => {
217+ it ( `returns ${ expected } for ${ name } ` , ( ) => {
218+ strictEqual ( createQueries . UNIST . isTypedList ( node ) , expected ) ;
219+ } ) ;
220+ } ) ;
221+ } ) ;
222+ } ) ;
113223} ) ;
0 commit comments