diff --git a/types/linkifyjs/element.d.ts b/types/linkifyjs/element.d.ts new file mode 100644 index 0000000000..27b06402b3 --- /dev/null +++ b/types/linkifyjs/element.d.ts @@ -0,0 +1,4 @@ +import { LinkifyOptions } from "./index"; + +export function linkifyElement(element: HTMLElement, options?: LinkifyOptions, doc?: HTMLDocument): HTMLElement; +export default linkifyElement; diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 02d9d3b6d5..266d21d075 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -1,6 +1,9 @@ import * as React from "react"; import linkifyHtml from "linkifyjs/html"; import Linkify from "linkifyjs/react"; +import linkifyStr from "linkifyjs/string"; +import linkifyElement from "linkifyjs/element"; +import { LinkifyOptions } from "linkifyjs"; declare function describe(desc: string, f: () => void): void; @@ -103,7 +106,7 @@ describe("linkifyjs/html", () => { linkifyHtml( // tslint:disable-next-line:prefer-template 'Please ignore \n' + - "but do b.ca", + "but do b.ca", { ignoreTags: ["script", "style"] } @@ -225,3 +228,25 @@ describe("linkifyjs/react", () => { ; } }); + +describe("linkifyjs/string", () => { + /** + * The following tests were based on the documentation: + * https://soapbox.github.io/linkifyjs/docs/linkify-string.html + */ + const options: LinkifyOptions = {}; + const str = '

For help with GitHub.com, please email support@github.com

'; + const result1: string = linkifyStr(str, options); + const result2: string = linkifyStr(str); +}); + +describe("linkifyjs/element", () => { + /** + * The following tests were based on the documentation: + * https://soapbox.github.io/linkifyjs/docs/linkify-element.html + */ + const options: LinkifyOptions = {}; + const result1: HTMLElement = linkifyElement(document.body, options, document); + const result2: HTMLElement = linkifyElement(document.body, options); + const result3: HTMLElement = linkifyElement(document.body); +}); diff --git a/types/linkifyjs/string.d.ts b/types/linkifyjs/string.d.ts new file mode 100644 index 0000000000..06f5573248 --- /dev/null +++ b/types/linkifyjs/string.d.ts @@ -0,0 +1,4 @@ +import { LinkifyOptions } from "./index"; + +export function linkifyStr(str: string, options?: LinkifyOptions): string; +export default linkifyStr; diff --git a/types/linkifyjs/tsconfig.json b/types/linkifyjs/tsconfig.json index 16becbcf0a..875789f909 100644 --- a/types/linkifyjs/tsconfig.json +++ b/types/linkifyjs/tsconfig.json @@ -13,5 +13,12 @@ "forceConsistentCasingInFileNames": true, "jsx": "preserve" }, - "files": ["index.d.ts", "html.d.ts", "react.d.ts", "linkifyjs-tests.tsx"] + "files": [ + "element.d.ts", + "html.d.ts", + "index.d.ts", + "linkifyjs-tests.tsx", + "react.d.ts", + "string.d.ts" + ] }