enrich commit mentions by internal links e. g. "repoNamespace/repoName@commitId"

This commit is contained in:
Eduard Heimbuch
2020-06-19 11:50:58 +02:00
parent caf97d41ed
commit 0eeddd5103
11 changed files with 252 additions and 14 deletions

View File

@@ -21,7 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import { isAnchorLink, isExternalLink, isLinkWithProtocol, createLocalLink } from "./MarkdownLinkRenderer";
import {
isAnchorLink,
isExternalLink,
isLinkWithProtocol,
createLocalLink,
isInternalScmRepoLink
} from "./MarkdownLinkRenderer";
describe("test isAnchorLink", () => {
it("should return true", () => {
@@ -67,6 +73,18 @@ describe("test isLinkWithProtocol", () => {
});
});
describe("test isInternalScmRepoLink", () => {
it("should return true", () => {
expect(isInternalScmRepoLink("/repo/scmadmin/git/code/changeset/1234567")).toBe(true);
expect(isInternalScmRepoLink("/repo/scmadmin/git")).toBe(true);
});
it("should return false", () => {
expect(isInternalScmRepoLink("repo/path/link")).toBe(false);
expect(isInternalScmRepoLink("/some/path/link")).toBe(false);
expect(isInternalScmRepoLink("#some-anchor")).toBe(false);
});
});
describe("test createLocalLink", () => {
it("should handle relative links", () => {
expectLocalLink("/src", "/src/README.md", "docs/Home.md", "/src/docs/Home.md");