Repository: eslint/eslint
File: tests/lib/eslint/flat-eslint.js (JavaScript)

Code before:
describe("shouldUseFlatConfig", () => {
    describe("when the env variable `ESLINT_USE_FLAT_CONFIG` is `'true'`", () => {
        beforeEach(() => {
            process.env.ESLINT_USE_FLAT_CONFIG = true;
        });

        afterEach(() => {
            delete process.env.ESLINT_USE_FLAT_CONFIG;
        });

        it("is `true`", async () => {
            assert.strictEqual(await shouldUseFlatConfig(true), true);
        });
    });

    describe("when the env variable `ESLINT_USE_FLAT_CONFIG` is `'false'`", () => {
        beforeEach(() => {
            process.env.ESLINT_USE_FLAT_CONFIG = false;
        });

        afterEach(() => {
            delete process.env.ESLINT_USE_FLAT_CONFIG;
        });

        it("is `false`", async () => {
            assert.strictEqual(await shouldUseFlatConfig(true), false);
        });
    });

    describe("when the env variable `ESLINT_USE_FLAT_CONFIG` is unset", () => {
        describe("when there is a flat config file present", () => {
            const originalDir = process.cwd();

            beforeEach(() => {
                process.chdir(__dirname);
            });

            afterEach(() => {
                process.chdir(originalDir);
            });

            it("is `true`", async () => {
                assert.strictEqual(await shouldUseFlatConfig(true), true);
            });
        });

        describe("when there is no flat config file present", () => {
            const originalDir = process.cwd();

            beforeEach(() => {
                process.chdir(os.tmpdir());

Review comment (suggestion):
```suggestion
            assert.strictEqual(await shouldUseFlatConfig(), false);
```

Code after:
describe("shouldUseFlatConfig", () => {

    /**
     * Check that `shouldUseFlatConfig` returns the expected value from a CWD
     * with a flat config and one without a flat config.
     * @param {boolean} expectedValueWithConfig the expected return value of
     * `shouldUseFlatConfig` when in a directory with a flat config present
     * @param {boolean} expectedValueWithoutConfig the expected return value of
     * `shouldUseFlatConfig` when in a directory without any flat config present
     * @returns {void}
     */
    function testShouldUseFlatConfig(expectedValueWithConfig, expectedValueWithoutConfig) {
        describe("when there is a flat config file present", () => {
            const originalDir = process.cwd();

            beforeEach(() => {
                process.chdir(__dirname);
            });

            afterEach(() => {
                process.chdir(originalDir);
            });

            it(`is \`${expectedValueWithConfig}\``, async () => {
                assert.strictEqual(await shouldUseFlatConfig(), expectedValueWithConfig);
            });
        });

        describe("when there is no flat config file present", () => {
            const originalDir = process.cwd();

            beforeEach(() => {
                process.chdir(os.tmpdir());
            });

            afterEach(() => {
                process.chdir(originalDir);
            });

            it(`is \`${expectedValueWithoutConfig}\``, async () => {
                assert.strictEqual(await shouldUseFlatConfig(), expectedValueWithoutConfig);
            });
        });
    }

    describe("when the env variable `ESLINT_USE_FLAT_CONFIG` is `'true'`", () => {
        beforeEach(() => {
            process.env.ESLINT_USE_FLAT_CONFIG = true;
        });

        afterEach(() => {