Skip to content

Commit

Permalink
Fix: Display pipe character correctly in test output (#12771)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher authored and platinumazure committed Jan 16, 2020
1 parent 68becbd commit 01ff791
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rule-tester/rule-tester.js
Expand Up @@ -174,7 +174,7 @@ function freezeDeeply(x) {
*/
function sanitize(text) {
return text.replace(
/[\u0000-\u0009|\u000b-\u001a]/gu, // eslint-disable-line no-control-regex
/[\u0000-\u0009\u000b-\u001a]/gu, // eslint-disable-line no-control-regex
c => `\\u${c.codePointAt(0).toString(16).padStart(4, "0")}`
);
}
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rule-tester/rule-tester.js
Expand Up @@ -1281,6 +1281,20 @@ describe("RuleTester", () => {
});
sinon.assert.calledWith(spyRuleTesterIt, "\\u0000");
});
it("should present the pipe character correctly", () => {
const code = "var foo = bar || baz;";

ruleTester.run("no-var", require("../../fixtures/testers/rule-tester/no-var"), {
valid: [],
invalid: [
{
code,
errors: [/^Bad var/u]
}
]
});
sinon.assert.calledWith(spyRuleTesterIt, code);
});

});
});

0 comments on commit 01ff791

Please sign in to comment.