Add test for helpers.getReferenceLinkImageData().shortcuts to verify non-shortcut link scenaros aren't mis-reported (closes #684).

This commit is contained in:
David Anson 2022-12-22 23:28:04 +00:00
parent 691b7afc52
commit f000a33481

View file

@ -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);
@ -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);
});