File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -206,6 +206,19 @@ mod tests {
206206 assert ! ( cache. get( & key) . is_some( ) ) ;
207207 }
208208
209+ #[ test]
210+ fn parse_error_surfaces_reason ( ) {
211+ // An unknown control sequence yields a message shown in the placeholder.
212+ let j = job ( "\\ unknowncmd{x}" , true ) ;
213+ let key = key_for ( & j) ;
214+ let cache = ImageCache :: new ( ) ;
215+ render_math_blocking ( & [ ( key. clone ( ) , j) ] , & cache) ;
216+ match cache. get ( & key) {
217+ Some ( ImageState :: Failed ( Some ( msg) ) ) => assert ! ( !msg. is_empty( ) ) ,
218+ _ => panic ! ( "expected Failed(Some(reason))" ) ,
219+ }
220+ }
221+
209222 #[ test]
210223 fn key_stable_and_distinguishes_display ( ) {
211224 assert_eq ! ( key_for( & job( "x" , true ) ) , key_for( & job( "x" , true ) ) ) ;
Original file line number Diff line number Diff line change @@ -132,6 +132,22 @@ mod tests {
132132 assert ! ( cache. get( & key) . is_some( ) ) ;
133133 }
134134
135+ #[ test]
136+ fn parse_error_surfaces_reason ( ) {
137+ // A parseable header with an unsupported construct yields a message (not just a
138+ // generic failure), so the placeholder can show the author what's wrong.
139+ let src = "classDiagram\n class A {\n <<interface>>\n }" ;
140+ let key = key_for ( src) ;
141+ let cache = ImageCache :: new ( ) ;
142+ render_mermaid_blocking ( & [ ( key. clone ( ) , src. to_string ( ) ) ] , & cache) ;
143+ match cache. get ( & key) {
144+ Some ( ImageState :: Failed ( Some ( msg) ) ) => {
145+ assert ! ( !msg. is_empty( ) , "error message should be non-empty" ) ;
146+ }
147+ _ => panic ! ( "expected Failed(Some(reason))" ) ,
148+ }
149+ }
150+
135151 #[ test]
136152 fn key_is_stable_per_source ( ) {
137153 assert_eq ! ( key_for( "graph LR; A-->B" ) , key_for( "graph LR; A-->B" ) ) ;
You can’t perform that action at this time.
0 commit comments