Skip to content

Commit

Permalink
chore: refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jan 19, 2024
1 parent c4a559c commit fc7c7ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/lib/cli-engine/file-enumerator.js
Expand Up @@ -457,7 +457,7 @@ describe("FileEnumerator", () => {
});

it("should throw an error if no files match a glob", () => {
const patterns = ["tests/fixtures/glob-util/ignored/**/*.js"];
const patterns = ["dir-does-not-exist/**/*.js"];

assert.throws(() => {
listFiles(patterns, { cwd: getFixturePath("ignored-paths") });
Expand Down
32 changes: 16 additions & 16 deletions tests/lib/eslint/eslint.js
Expand Up @@ -286,6 +286,22 @@ describe("ESLint", () => {
].join("\n")), "u")
);
});

it("should warn if .eslintignore file is present", async () => {
const cwd = getFixturePath("ignored-paths");

sinon.restore();
const processStub = sinon.stub(process, "emitWarning");

// eslint-disable-next-line no-new -- for testing purpose only
new ESLint({ cwd });

assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
assert.strictEqual(processStub.getCall(0).args[0], "The \".eslintignore\" file is no longer supported. Switch to using the \"ignores\" property in \"eslint.config.js\": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files");
assert.strictEqual(processStub.getCall(0).args[1], "ESLintIgnoreWarning");

processStub.restore();
});
});

describe("lintText()", () => {
Expand Down Expand Up @@ -4608,22 +4624,6 @@ describe("ESLint", () => {

await assert.rejects(() => eslint.isPathIgnored(null), /'filePath' must be a non-empty string/u);
});

it("should warn if .eslintignore file is present", async () => {
const cwd = getFixturePath("ignored-paths");

sinon.restore();
const processStub = sinon.stub(process, "emitWarning");

// eslint-disable-next-line no-new -- for testing purpose only
new ESLint({ cwd });

assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
assert.strictEqual(processStub.getCall(0).args[0], "The \".eslintignore\" file is no longer supported. Switch to using the \"ignores\" property in \"eslint.config.js\": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files");
assert.strictEqual(processStub.getCall(0).args[1], "ESLintIgnoreWarning");

processStub.restore();
});
});

describe("loadFormatter()", () => {
Expand Down

0 comments on commit fc7c7ac

Please sign in to comment.