@@ -76,7 +76,7 @@ const base = getConverter2Base();
7676const app = getConverter2App ( ) ;
7777const program = getConverter2Program ( ) ;
7878
79- function doConvert ( entry : string ) {
79+ function convert ( entry : string ) {
8080 const entryPoint = [
8181 join ( base , `behavior/${ entry } .ts` ) ,
8282 join ( base , `behavior/${ entry } .d.ts` ) ,
@@ -91,6 +91,7 @@ function doConvert(entry: string) {
9191 ok ( sourceFile , `No source file found for ${ entryPoint } ` ) ;
9292
9393 app . options . setValue ( "entryPoints" , [ entryPoint ] ) ;
94+ clearCommentCache ( ) ;
9495 return app . converter . convert ( [
9596 {
9697 displayName : entry ,
@@ -102,14 +103,11 @@ function doConvert(entry: string) {
102103
103104describe ( "Behavior Tests" , ( ) => {
104105 let logger : TestLogger ;
105- let convert : ( name : string ) => ProjectReflection ;
106106 let optionsSnap : { __optionSnapshot : never } ;
107107
108108 beforeEach ( ( ) => {
109109 app . logger = logger = new TestLogger ( ) ;
110110 optionsSnap = app . options . snapshot ( ) ;
111- clearCommentCache ( ) ;
112- convert = ( name ) => doConvert ( name ) ;
113111 } ) ;
114112
115113 afterEach ( ( ) => {
@@ -261,7 +259,35 @@ describe("Behavior Tests", () => {
261259 ] ) ;
262260 } ) ;
263261
264- it ( "Handles example tags" , ( ) => {
262+ it ( "Handles @default tags with JSDoc compat turned on" , ( ) => {
263+ const project = convert ( "defaultTag" ) ;
264+ const foo = query ( project , "foo" ) ;
265+ const tags = foo . comment ?. blockTags . map ( ( tag ) => tag . content ) ;
266+
267+ equal ( tags , [
268+ [ { kind : "code" , text : "```ts\n\n```" } ] ,
269+ [ { kind : "code" , text : "```ts\nfn({})\n```" } ] ,
270+ ] ) ;
271+
272+ logger . expectNoOtherMessages ( ) ;
273+ } ) ;
274+
275+ it ( "Handles @default tags with JSDoc compat turned off" , ( ) => {
276+ app . options . setValue ( "jsDocCompatibility" , false ) ;
277+ const project = convert ( "defaultTag" ) ;
278+ const foo = query ( project , "foo" ) ;
279+ const tags = foo . comment ?. blockTags . map ( ( tag ) => tag . content ) ;
280+
281+ equal ( tags , [ [ ] , [ { kind : "text" , text : "fn({})" } ] ] ) ;
282+
283+ logger . expectMessage (
284+ "warn: Encountered an unescaped open brace without an inline tag"
285+ ) ;
286+ logger . expectMessage ( "warn: Unmatched closing brace" ) ;
287+ logger . expectNoOtherMessages ( ) ;
288+ } ) ;
289+
290+ it ( "Handles @example tags with JSDoc compat turned on" , ( ) => {
265291 const project = convert ( "exampleTags" ) ;
266292 const foo = query ( project , "foo" ) ;
267293 const tags = foo . comment ?. blockTags . map ( ( tag ) => tag . content ) ;
@@ -288,6 +314,36 @@ describe("Behavior Tests", () => {
288314 logger . expectNoOtherMessages ( ) ;
289315 } ) ;
290316
317+ it ( "Warns about example tags containing braces when compat options are off" , ( ) => {
318+ app . options . setValue ( "jsDocCompatibility" , false ) ;
319+ const project = convert ( "exampleTags" ) ;
320+ const foo = query ( project , "foo" ) ;
321+ const tags = foo . comment ?. blockTags . map ( ( tag ) => tag . content ) ;
322+
323+ equal ( tags , [
324+ [ { kind : "text" , text : "// JSDoc style\ncodeHere();" } ] ,
325+ [
326+ {
327+ kind : "text" ,
328+ text : "<caption>JSDoc specialness</caption>\n// JSDoc style\ncodeHere();" ,
329+ } ,
330+ ] ,
331+ [
332+ {
333+ kind : "text" ,
334+ text : "<caption>JSDoc with braces</caption>\nx.map(() => { return 1; })" ,
335+ } ,
336+ ] ,
337+ [ { kind : "code" , text : "```ts\n// TSDoc style\ncodeHere();\n```" } ] ,
338+ ] ) ;
339+
340+ logger . expectMessage (
341+ "warn: Encountered an unescaped open brace without an inline tag"
342+ ) ;
343+ logger . expectMessage ( "warn: Unmatched closing brace" ) ;
344+ logger . expectNoOtherMessages ( ) ;
345+ } ) ;
346+
291347 it ( "Handles excludeNotDocumentedKinds" , ( ) => {
292348 app . options . setValue ( "excludeNotDocumented" , true ) ;
293349 app . options . setValue ( "excludeNotDocumentedKinds" , [ "Property" ] ) ;
0 commit comments