diff --git a/tests/integration.js b/tests/integration.js index f23ee7a..255e5ff 100644 --- a/tests/integration.js +++ b/tests/integration.js @@ -3,15 +3,23 @@ const assert = require("chai").assert; const plugin = require("../lib/index.js"); const { ESLint } = require("eslint"); -describe("Integration tests", () => { - const eslint = new ESLint({ - fix: true, - overrideConfigFile: "./tests/eslint.test.config.js", - overrideConfig: { - processor: plugin.processors.processorJs, - }, - }); +const eslint = new ESLint({ + fix: true, + overrideConfigFile: "./tests/eslint.test.config.js", + overrideConfig: { + processor: plugin.processors.processorJs, + files: ["**/*.js"], + }, +}); + +async function runTest(filename, expectedFilename) { + const testCode = fs.readFileSync(filename, "utf-8"); + const result = await eslint.lintText(testCode, { filePath: filename }); + const expectedCode = fs.readFileSync(expectedFilename, "utf-8"); + assert.strictEqual(result[0].output, expectedCode); +} +describe("Integration tests (JS)", () => { const mapFiles = [ "common", "each-do", @@ -22,13 +30,7 @@ describe("Integration tests", () => { ]; mapFiles.forEach((name) => { it(`performs linting as we expect it on ${name}.js`, async () => { - const filename = `tests/fixtures/${name}.js`; - const testCode = fs.readFileSync(filename, "utf-8"); - - const result = await eslint.lintText(testCode, { filePath: filename }); - - const expectedCode = fs.readFileSync(`tests/fixtures/${name}.expected.js`, "utf-8"); - assert.strictEqual(result[0].output, expectedCode); + await runTest(`tests/fixtures/${name}.js`, `tests/fixtures/${name}.expected.js`, eslint); }); }); });