Skip to content

Commit

Permalink
Add test for helpers.getReferenceLinkImageData().shortcuts to verify …
Browse files Browse the repository at this point in the history
…non-shortcut link scenaros aren't mis-reported (closes #684).
  • Loading branch information
DavidAnson committed Dec 22, 2022
1 parent 691b7af commit f000a33
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/markdownlint-test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const os = require("node:os");
const path = require("node:path");
const test = require("ava").default;
const helpers = require("../helpers");
const { markdownlint } = require("../lib/markdownlint").promises;

test("clearHtmlCommentTextValid", (t) => {
t.plan(1);
Expand Down Expand Up @@ -1482,3 +1483,35 @@ Text <> text
}
t.deepEqual(actual, expected);
});

test("getReferenceLinkImageData().shortcuts", (t) => {
t.plan(1);
const options = {
"customRules": [
{
"names": [ "no-shortcut-links" ],
"description": "-",
"tags": [ "-" ],
"function":
(params) => {
const lineMetadata = helpers.getLineMetadata(params);
const { shortcuts } =
helpers.getReferenceLinkImageData(lineMetadata);
t.is(shortcuts.size, 0, [ ...shortcuts.keys() ].join(", "));
}
}
],
"strings": {
"no-shortcut-links": `
Full reference link: [text0][label]
Collapsed reference link: [label][]
Nested empty brackets: [text1[]](https://example.com/)
Missing close bracket, empty text: [text2[](https://example.com/)
Empty bracket pairs: [text3[]][]
[label]: https://example.com/label
`
}
};
return markdownlint(options).then(() => null);
});

0 comments on commit f000a33

Please sign in to comment.