Skip to content

Commit

Permalink
Fix: exclude \u000d so new line won't convert to text (fixes eslint…
Browse files Browse the repository at this point in the history
…#12027)

add tests
  • Loading branch information
Ran.Itzhaki committed Jul 28, 2019
1 parent 02d7542 commit ea22f78
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion tests/lib/rule-tester/rule-tester.js
Expand Up @@ -324,7 +324,12 @@ describe("RuleTester", () => {
"bar = baz;"
],
invalid: [
{ code: "var foo = bar; var qux = boop;", output: null, errors: 2 }
{
code: `var foo = bar;
var qux = boop;`,
output: null,
errors: 2
}
]
});
}, /Expected no autofixes to be suggested/u);
Expand Down Expand Up @@ -1072,4 +1077,52 @@ describe("RuleTester", () => {
);
}, /A fatal parsing error occurred in autofix/u);
});

describe("sanitize test cases", () => {
let originalRuleTesterIt;
let spyRuleTesterIt;

before(() => {
originalRuleTesterIt = RuleTester.it;
spyRuleTesterIt = sinon.spy();
RuleTester.it = spyRuleTesterIt;
});
after(() => {
RuleTester.it = originalRuleTesterIt;
});
beforeEach(() => {
spyRuleTesterIt.resetHistory();
ruleTester = new RuleTester();
});
it("should present newline when using back-tick as new line", () => {
const code = `
var foo = bar;`;

ruleTester.run("no-var", require("../../fixtures/testers/rule-tester/no-var"), {
valid: [],
invalid: [
{
code,
errors: [/^Bad var/u]
}
]
});
sinon.assert.calledWith(spyRuleTesterIt, code);
});
it("should present \\u0000 as a string", () => {
const code = "\u0000";

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

});
});

0 comments on commit ea22f78

Please sign in to comment.