Skip to content

Commit

Permalink
fix: new line between Default is
Browse files Browse the repository at this point in the history
issue: #176
  • Loading branch information
hosseinmd committed Oct 5, 2023
1 parent 4f9ba4c commit 9fbbe53
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.ts
Expand Up @@ -533,7 +533,7 @@ function addDefaultValueToDescription(tag: Spec): Spec {
let { description } = tag;

// remove old note
description = description.replace(/[ \t]*Default is `.*`\.?$/, "");
description = description.replace(/[\s]*Default[\s]*is[\s]*`.*`\.?$/, "");

// add a `.` at the end of previous sentences
if (description && !/[.\n]$/.test(description)) {
Expand Down
9 changes: 9 additions & 0 deletions tests/__snapshots__/main.test.ts.snap
Expand Up @@ -413,6 +413,15 @@ exports[`Sould keep params ordering when more than 10 tags are present 1`] = `
"
`;
exports[`default type parameter 1`] = `
"/**
* @template [BAR=({bar:true}&{foo:false}&{buggy:true})] Default is
* \`({bar:true}&{foo:false}&{buggy:true})\`
* @typedef {{ foo: BAR }} SomeType
*/
"
`;
exports[`example 1`] = `
"/**
* ABCCCC
Expand Down
18 changes: 18 additions & 0 deletions tests/main.test.ts
Expand Up @@ -802,3 +802,21 @@ test("satisfies", async () => {

expect(result).toMatchSnapshot();
});

test("default type parameter ", async () => {
function _subject(str: string) {
return subject(str, {
jsdocAddDefaultToDescription: true,
});
}
const result = await _subject(
`
/**
* @template [BAR=({bar:true}&{foo:false}&{buggy:true})]
* @typedef {{foo: BAR}} SomeType
*/
`,
);

expect(await _subject(await _subject(result))).toMatchSnapshot();
});

0 comments on commit 9fbbe53

Please sign in to comment.