-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor:
JSDocTag.getName()
should be .getTagName()
BREAKING CHANGE: `JSDocTag`'s `.getName()` is now `.getTagName()`. This was necessary because `.getName()` should return a `JSDocPropertyLikeTag`'s name.
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { expect } from "chai"; | ||
import { JSDocTag } from "../../../compiler"; | ||
import { TypeGuards } from "../../../utils"; | ||
import { getInfoFromText } from "../testHelpers"; | ||
|
||
describe(nameof(JSDocTag), () => { | ||
function getInfo(text: string) { | ||
const info = getInfoFromText(text); | ||
return { descendant: info.sourceFile.getFirstDescendantOrThrow(TypeGuards.isJSDocTag), ...info }; | ||
} | ||
|
||
describe(nameof<JSDocTag>(d => d.getAtToken), () => { | ||
it("should get the at token", () => { | ||
const { descendant } = getInfo("/** @param t - String */\nfunction test() {}"); | ||
expect(descendant.getAtToken().getText()).to.equal("@"); | ||
}); | ||
}); | ||
|
||
describe(nameof<JSDocTag>(d => d.getTagName), () => { | ||
it("should get the tag name", () => { | ||
const { descendant } = getInfo("/** @param t - String */\nfunction test() {}"); | ||
expect(descendant.getTagName()).to.equal("param"); | ||
}); | ||
}); | ||
|
||
describe(nameof<JSDocTag>(d => d.getTagNameNode), () => { | ||
it("should get the tag name node", () => { | ||
const { descendant } = getInfo("/** @param t - String */\nfunction test() {}"); | ||
expect(descendant.getTagNameNode().getText()).to.equal("param"); | ||
}); | ||
}); | ||
|
||
describe(nameof<JSDocTag>(d => d.getComment), () => { | ||
function doTest(text: string, expected: string | undefined) { | ||
const { descendant } = getInfo(text); | ||
expect(descendant.getComment()).to.equal(expected); | ||
} | ||
|
||
it("should get the tag comment", () => { | ||
doTest("/** @param t - String*/\nfunction test() {}", "- String"); | ||
}); | ||
|
||
it("should return undefined when not exists", () => { | ||
doTest("/** @param */\nfunction test() {}", undefined); | ||
}); | ||
}); | ||
}); |