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

Code before:

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

            it("should remove BOM with a negative range", () => {
                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", () => {

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

Code after:

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

            it("should remove BOM with a negative range", () => {
                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", () => {