@@ -48,4 +48,52 @@ describe(frontmatterSchema.names.join(' - '), () => {
4848 expect ( errors [ 0 ] . lineNumber ) . toBe ( 1 )
4949 expect ( errors [ 0 ] . errorRange ) . toEqual ( null )
5050 } )
51+
52+ test ( 'sidebarLink with valid object properties passes' , async ( ) => {
53+ const markdown = [
54+ '---' ,
55+ 'title: Title' ,
56+ 'versions:' ,
57+ " fpt: '*'" ,
58+ 'sidebarLink:' ,
59+ ' text: "All prompts"' ,
60+ ' href: "/copilot/copilot-chat-cookbook"' ,
61+ '---' ,
62+ ] . join ( '\n' )
63+ const result = await runRule ( frontmatterSchema , { strings : { markdown } , ...fmOptions } )
64+ const errors = result . markdown
65+ expect ( errors . length ) . toBe ( 0 )
66+ } )
67+
68+ test ( 'sidebarLink with missing text property fails' , async ( ) => {
69+ const markdown = [
70+ '---' ,
71+ 'title: Title' ,
72+ 'versions:' ,
73+ " fpt: '*'" ,
74+ 'sidebarLink:' ,
75+ ' href: "/copilot/copilot-chat-cookbook"' ,
76+ '---' ,
77+ ] . join ( '\n' )
78+ const result = await runRule ( frontmatterSchema , { strings : { markdown } , ...fmOptions } )
79+ const errors = result . markdown
80+ expect ( errors . length ) . toBe ( 1 )
81+ expect ( errors [ 0 ] . lineNumber ) . toBe ( 5 )
82+ } )
83+
84+ test ( 'sidebarLink with missing href property fails' , async ( ) => {
85+ const markdown = [
86+ '---' ,
87+ 'title: Title' ,
88+ 'versions:' ,
89+ " fpt: '*'" ,
90+ 'sidebarLink:' ,
91+ ' text: "All prompts"' ,
92+ '---' ,
93+ ] . join ( '\n' )
94+ const result = await runRule ( frontmatterSchema , { strings : { markdown } , ...fmOptions } )
95+ const errors = result . markdown
96+ expect ( errors . length ) . toBe ( 1 )
97+ expect ( errors [ 0 ] . lineNumber ) . toBe ( 5 )
98+ } )
5199} )
0 commit comments