eslint-tester
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -0,1 +1,9 @@ | ||
v0.2.0 - September 5, 2014 | ||
* 0.2.0 (Nicholas C. Zakas) | ||
* New: testing correct column (fixes #3) (Mathias Schreck) | ||
* Update: Node 0.8 no longer supported (Mathias Schreck) | ||
* Update: improve test coverage (fixes #4) (Mathias Schreck) | ||
* 0.1.0 (Nicholas C. Zakas) | ||
v0.1.0 - May 20, 2014 | ||
@@ -2,0 +10,0 @@ |
@@ -119,16 +119,17 @@ /** | ||
if (messages.length === item.errors.length) { | ||
for (var i = 0, l = item.errors.length; i < l; i++) { | ||
assert.ok(!("fatal" in messages[i]), "A fatal parsing error occurred: " + messages[i].message); | ||
assert.equal(messages[i].ruleId, ruleName, "Error rule name should be the same as the name of the rule being tested"); | ||
if (item.errors[i].message) { | ||
assert.equal(messages[i].message, item.errors[i].message, "Error message should be " + item.errors[i].message); | ||
} | ||
if (item.errors[i].type) { | ||
assert.equal(messages[i].node.type, item.errors[i].type, "Error type should be " + item.errors[i].type); | ||
} | ||
if (item.errors[i].line) { | ||
assert.equal(messages[i].line, item.errors[i].line, "Error line should be " + item.errors[i].line); | ||
} | ||
for (var i = 0, l = item.errors.length; i < l; i++) { | ||
assert.ok(!("fatal" in messages[i]), "A fatal parsing error occurred: " + messages[i].message); | ||
assert.equal(messages[i].ruleId, ruleName, "Error rule name should be the same as the name of the rule being tested"); | ||
if (item.errors[i].message) { | ||
assert.equal(messages[i].message, item.errors[i].message, "Error message should be " + item.errors[i].message); | ||
} | ||
if (item.errors[i].type) { | ||
assert.equal(messages[i].node.type, item.errors[i].type, "Error type should be " + item.errors[i].type); | ||
} | ||
if (item.errors[i].line) { | ||
assert.equal(messages[i].line, item.errors[i].line, "Error line should be " + item.errors[i].line); | ||
} | ||
if (item.errors[i].column) { | ||
assert.equal(messages[i].column, item.errors[i].column, "Error column should be " + item.errors[i].column); | ||
} | ||
} | ||
@@ -135,0 +136,0 @@ } |
{ | ||
"name": "eslint-tester", | ||
"author": "Nicholas C. Zakas", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A testing utility for ESLint", | ||
@@ -29,3 +29,6 @@ "main": "lib/eslint-tester.js", | ||
"eslint": "latest" | ||
}, | ||
"engines": { | ||
"node": ">=0.10" | ||
} | ||
} |
@@ -0,0 +0,0 @@ /** |
@@ -153,2 +153,17 @@ /** | ||
it("should throw an error if invalid code specifies wrong column", function() { | ||
var wrongColumn = 10, | ||
expectedErrorMessage = "Error column should be 1"; | ||
assert.throws(function() { | ||
eslintTester.addRuleTest("tests/fixtures/no-eval", { | ||
valid: [ "Eval(foo)" ], | ||
invalid: [ { | ||
code: "eval(foo)", | ||
errors: [ { message: "eval sucks.", column: wrongColumn } ] | ||
} ] | ||
}); | ||
}, expectedErrorMessage); | ||
}); | ||
it("should throw an error if invalid code has the wrong number of errors", function() { | ||
@@ -185,2 +200,77 @@ | ||
it("should not throw an error if invalid code has at least an expected empty error object", function() { | ||
assert.doesNotThrow(function() { | ||
eslintTester.addRuleTest("tests/fixtures/no-eval", { | ||
valid: [ "Eval(foo)" ], | ||
invalid: [ { | ||
code: "eval(foo)", | ||
errors: [ {} ] | ||
} ] | ||
}); | ||
}); | ||
}); | ||
it("should pass-through the globals config of valid tests to the to rule", function() { | ||
assert.doesNotThrow(function() { | ||
eslintTester.addRuleTest("tests/fixtures/no-test-global", { | ||
valid: [ | ||
"var test = 'foo'", | ||
{ | ||
code: "var test2 = 'bar'", | ||
globals: { test: true } | ||
}, | ||
{ | ||
code: "var test2 = 'bar'", | ||
global: { test: true } | ||
} | ||
], | ||
invalid: [ { code: "bar", errors: 1 } ] | ||
}); | ||
}); | ||
}); | ||
it("should pass-through the globals config of invalid tests to the to rule", function() { | ||
assert.doesNotThrow(function() { | ||
eslintTester.addRuleTest("tests/fixtures/no-test-global", { | ||
valid: [ "var test = 'foo'" ], | ||
invalid: [ | ||
{ | ||
code: "var test = 'foo'; var foo = 'bar'", | ||
errors: 1 | ||
}, | ||
{ | ||
code: "var test = 'foo'", | ||
globals: { foo: true }, | ||
errors: [ { message: "Global variable foo should not be used." } ] | ||
}, | ||
{ | ||
code: "var test = 'foo'", | ||
global: { foo: true }, | ||
errors: [ { message: "Global variable foo should not be used." } ] | ||
} | ||
] | ||
}); | ||
}); | ||
}); | ||
it("should pass-through the args to the rule", function() { | ||
assert.doesNotThrow(function() { | ||
eslintTester.addRuleTest("tests/fixtures/no-invalid-args", { | ||
valid: [ | ||
{ | ||
code: "var foo = 'bar'", | ||
args: [ 1, false ] | ||
} | ||
], | ||
invalid: [ | ||
{ | ||
code: "var foo = 'bar'", | ||
args: [ 1, true ], | ||
errors: [ { message: "Invalid args" } ] | ||
} | ||
] | ||
}); | ||
}); | ||
}); | ||
it("should throw an error if there are no valid tests", function() { | ||
@@ -187,0 +277,0 @@ |
Sorry, the diff of this file is not supported yet
27287
16
586