Skip to content

Commit

Permalink
Use String.raw to improve readability of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Apr 4, 2020
1 parent 420a983 commit 8304054
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/lib/linter/linter.js
Expand Up @@ -2733,7 +2733,10 @@ describe("Linter", () => {
});

describe("when evaluating code with comments which have colon in its value", () => {
const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\\\s*require\\\\s*\\\\(|^\\\\s*loader\\\\.lazy|-\\\\*-\"}] */\nalert('test');";
const code = String.raw`
/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: "data:image\/|\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-"}] */
alert('test');
`;

it("should not parse errors, should report a violation", () => {
const messages = linter.verify(code, {}, filename);
Expand All @@ -2746,7 +2749,11 @@ describe("Linter", () => {
});

describe("when evaluating code with comments that contain escape sequences", () => {
const code = '/* eslint max-len: ["error", 1, { ignoreComments: true, ignorePattern: "console\\.log\\\\(" }] */\nconsole.log("test");\nvar a = "test2";';
const code = String.raw`
/* eslint max-len: ["error", 1, { ignoreComments: true, ignorePattern: "console\.log\\(" }] */
console.log("test");
var a = "test2";
`;

it("should validate correctly", () => {
const config = { rules: {} };
Expand All @@ -2756,7 +2763,7 @@ describe("Linter", () => {
assert.strictEqual(messages.length, 1);
assert.strictEqual(messages[0].ruleId, "max-len");
assert.strictEqual(messages[0].message, "This line has a length of 16. Maximum allowed is 1.");
assert.strictEqual(messages[0].line, 3);
assert.strictEqual(messages[0].line, 4);
assert.strictEqual(messages[0].column, 1);
assert.include(messages[0].nodeType, "Program");
});
Expand Down

0 comments on commit 8304054

Please sign in to comment.