mirror of
https://github.com/theoludwig/markdownlint-rule-relative-links.git
synced 2025-05-27 11:37:24 +02:00
fix: cleaner code + better error messages
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
const test = require("node:test")
|
||||
const { test } = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
|
||||
const { markdownlint } = require("markdownlint").promises
|
||||
@ -14,33 +14,33 @@ test("ensure the rule validate correctly", async () => {
|
||||
},
|
||||
customRules: [relativeLinks],
|
||||
})
|
||||
assert.equal(lintResults["test/fixtures/Valid.md"].length, 0)
|
||||
assert.equal(lintResults["test/fixtures/Invalid.md"].length, 3)
|
||||
assert.equal(lintResults["test/fixtures/Valid.md"]?.length, 0)
|
||||
assert.equal(lintResults["test/fixtures/Invalid.md"]?.length, 3)
|
||||
|
||||
assert.equal(
|
||||
lintResults["test/fixtures/Invalid.md"][0]?.ruleDescription,
|
||||
lintResults["test/fixtures/Invalid.md"]?.[0]?.ruleDescription,
|
||||
"Relative links should be valid",
|
||||
)
|
||||
assert.equal(
|
||||
lintResults["test/fixtures/Invalid.md"][0]?.errorDetail,
|
||||
'Link "./basic.test.js" should exist in the file system',
|
||||
lintResults["test/fixtures/Invalid.md"]?.[0]?.errorDetail,
|
||||
'"./basic.test.js" should exist in the file system',
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
lintResults["test/fixtures/Invalid.md"][1]?.ruleDescription,
|
||||
lintResults["test/fixtures/Invalid.md"]?.[1]?.ruleDescription,
|
||||
"Relative links should be valid",
|
||||
)
|
||||
assert.equal(
|
||||
lintResults["test/fixtures/Invalid.md"][1]?.errorDetail,
|
||||
'Link "../image.png" should exist in the file system',
|
||||
lintResults["test/fixtures/Invalid.md"]?.[1]?.errorDetail,
|
||||
'"../image.png" should exist in the file system',
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
lintResults["test/fixtures/Invalid.md"][2]?.ruleDescription,
|
||||
lintResults["test/fixtures/Invalid.md"]?.[2]?.ruleDescription,
|
||||
"Relative links should be valid",
|
||||
)
|
||||
assert.equal(
|
||||
lintResults["test/fixtures/Invalid.md"][2]?.errorDetail,
|
||||
'Link "./Valid.md#not-existing-heading" should have a valid fragment',
|
||||
lintResults["test/fixtures/Invalid.md"]?.[2]?.errorDetail,
|
||||
'"./Valid.md#not-existing-heading" should have a valid fragment identifier',
|
||||
)
|
||||
})
|
||||
|
@ -1,4 +1,4 @@
|
||||
const test = require("node:test")
|
||||
const { test } = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
|
||||
const {
|
||||
|
Reference in New Issue
Block a user