Repository: eslint/eslint
File: tests/lib/linter/source-code-fixer.js (JavaScript)

Code before:
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [REMOVE_BOM]);

                assert.strictEqual(result.output, TEST_CODE);
                assert.isTrue(result.fixed);
                assert.strictEqual(result.messages.length, 0);
            });

            it("should replace BOM with a negative range and 'foobar'", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [REPLACE_BOM_WITH_TEXT]);

                assert.strictEqual(result.output, `// start\n${TEST_CODE}`);
                assert.isTrue(result.fixed);
                assert.strictEqual(result.messages.length, 0);
            });

        });

        describe("Nil fix", () => {
            it("should not throw if fix equal null", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [NULL_FIX]);

                assert.isFalse(result.fixed);
                assert.strictEqual(result.output, TEST_CODE);
            });

            it("should not throw if fix equal undefined", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [UNDEFINED_FIX]);

                assert.isFalse(result.fixed);
                assert.strictEqual(result.output, TEST_CODE);
            });
        });

    });

    /*
     * This section is almost same as "with no BOM".
     * Just `result.output` has BOM.
     */
    describe("applyFixes() with BOM", () => {

        const TEST_CODE_WITH_BOM = `\uFEFF${TEST_CODE}`;

        describe("Text Insertion", () => {

            it("should insert text at the end of the code", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE_WITH_BOM, [INSERT_AT_END]);

                assert.strictEqual(result.output, `\uFEFF${TEST_CODE}${INSERT_AT_END.fix.text}`);
                assert.strictEqual(result.messages.length, 0);
            });

Review comment (suggestion):
```suggestion
            it("should not throw if fix is undefined", () => {
```

Code after:
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [REMOVE_BOM]);

                assert.strictEqual(result.output, TEST_CODE);
                assert.isTrue(result.fixed);
                assert.strictEqual(result.messages.length, 0);
            });

            it("should replace BOM with a negative range and 'foobar'", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [REPLACE_BOM_WITH_TEXT]);

                assert.strictEqual(result.output, `// start\n${TEST_CODE}`);
                assert.isTrue(result.fixed);
                assert.strictEqual(result.messages.length, 0);
            });

        });

        describe("Nullish fixes", () => {
            it("should not throw if fix is null", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [NULL_FIX]);

                assert.isFalse(result.fixed);
                assert.strictEqual(result.output, TEST_CODE);
                assert.strictEqual(result.messages.length, 1);
                assert.strictEqual(result.messages[0].message, "null");
            });

            it("should not throw if fix is undefined", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE, [UNDEFINED_FIX]);

                assert.isFalse(result.fixed);
                assert.strictEqual(result.output, TEST_CODE);
                assert.strictEqual(result.messages.length, 1);
                assert.strictEqual(result.messages[0].message, "undefined");
            });
        });

    });

    /*
     * This section is almost same as "with no BOM".
     * Just `result.output` has BOM.
     */
    describe("applyFixes() with BOM", () => {

        const TEST_CODE_WITH_BOM = `\uFEFF${TEST_CODE}`;

        describe("Text Insertion", () => {

            it("should insert text at the end of the code", () => {
                const result = SourceCodeFixer.applyFixes(TEST_CODE_WITH_BOM, [INSERT_AT_END]);