Skip to content

Commit

Permalink
Add test with conditional shouldFix
Browse files Browse the repository at this point in the history
This is to verify that the problem can be used to return true or false
conditionally, and that eslint will only apply fixes when true is
returned.
  • Loading branch information
IanVS committed Jun 25, 2017
1 parent da3d7b9 commit 73f556d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/lib/util/source-code-fixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ describe("SourceCodeFixer", () => {
assert.equal(result.output, TEST_CODE);
});

it("should only apply fixes for which the 'shouldFix' function returns true", () => {
const shouldFixSpy = sinon.spy(problem => problem.message === "foo");
const result = SourceCodeFixer.applyFixes(sourceCode, [INSERT_AT_START, REPLACE_ID], shouldFixSpy);

assert.equal(result.output, "var foo = 6 * 7;");
});

it("is called without access to internal eslint state", () => {
const shouldFixSpy = sinon.spy();

Expand Down

0 comments on commit 73f556d

Please sign in to comment.