Update applyFix to make line ending optional, MD047 to highlight only last character.

This commit is contained in:
David Anson 2019-09-20 21:50:44 -07:00
parent d974e78e3f
commit 4843e277c0
4 changed files with 52 additions and 4 deletions

View file

@ -578,7 +578,7 @@ module.exports.resultFormattingV3 = function resultFormattingV3(test) {
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`,
"errorDetail": null,
"errorContext": null,
"errorRange": null,
"errorRange": [ 15, 1 ],
"fixInfo": {
"insertText": "\n",
"editColumn": 16
@ -1945,6 +1945,54 @@ module.exports.getPreferredLineEnding = function getPreferredLineEnding(test) {
test.done();
};
module.exports.applyFix = function applyFix(test) {
test.expect(4);
const testCases = [
[
"Hello world.",
{
"editColumn": 12,
"deleteCount": 1
},
undefined,
"Hello world"
],
[
"Hello world.",
{
"editColumn": 13,
"insertText": "\n"
},
undefined,
"Hello world.\n"
],
[
"Hello world.",
{
"editColumn": 13,
"insertText": "\n"
},
"\n",
"Hello world.\n"
],
[
"Hello world.",
{
"editColumn": 13,
"insertText": "\n"
},
"\r\n",
"Hello world.\r\n"
]
];
testCases.forEach((testCase) => {
const [ line, fixInfo, lineEnding, expected ] = testCase;
const actual = helpers.applyFix(line, fixInfo, lineEnding);
test.equal(actual, expected, "Incorrect fix applied.");
});
test.done();
};
module.exports.applyFixes = function applyFixes(test) {
test.expect(28);
const testCases = [