eslint-plugin-jasmine
Advanced tools
Comparing version 2.10.0 to 2.10.1
@@ -37,2 +37,8 @@ # Disallow using promise without a done.fail (no-promise-without-done-fail). | ||
it('A spec', function() { | ||
asyncCall().then(done.fail, onError); | ||
}); | ||
}); | ||
describe('A suite', function(done) { | ||
it('A spec', function() { | ||
asyncCall().then(function() { | ||
@@ -44,2 +50,11 @@ expect(true).toBe(true); | ||
}); | ||
describe('A suite', function(done) { | ||
it('A spec', function() { | ||
asyncCall().then(done.fail).catch(function() { | ||
expect(true).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
``` |
@@ -15,4 +15,3 @@ 'use strict' | ||
function hasDoneFailInReject (node, asyncParam) { | ||
var reject = node.arguments[1] | ||
function hasDoneFail (reject, asyncParam) { | ||
return reject && | ||
@@ -24,6 +23,12 @@ reject.type === 'MemberExpression' && | ||
function hasDoneFailArgument (node, asyncParam) { | ||
var resolve = node.arguments[0] | ||
var reject = node.arguments[1] | ||
return hasDoneFail(resolve, asyncParam) || hasDoneFail(reject, asyncParam) | ||
} | ||
function isPromiseThenWithoutCatch (node, asyncParam) { | ||
return hasIdentifier(node, 'then') && | ||
!hasIdentifier(node.parent.parent, 'then') && | ||
!hasDoneFailInReject(node, asyncParam) && | ||
!hasDoneFailArgument(node, asyncParam) && | ||
!hasIdentifier(node.parent.parent, 'catch') | ||
@@ -30,0 +35,0 @@ } |
@@ -54,3 +54,3 @@ { | ||
}, | ||
"version": "2.10.0" | ||
"version": "2.10.1" | ||
} |
@@ -25,2 +25,5 @@ 'use strict' | ||
{ | ||
code: 'it("", function (done) { asyncFunc.then(done.fail, done);})' | ||
}, | ||
{ | ||
code: 'it("should not care about the name of the first parameter", function (finished) { somethingAsync().then(finished, finished.fail);});' | ||
@@ -41,2 +44,5 @@ }, | ||
{ | ||
code: 'it("", (done) => { asyncFunc.then(done.fail, done);})' | ||
}, | ||
{ | ||
code: 'it("should not care about the name of the first parameter", (finished) => { somethingAsync().then(finished, finished.fail);});' | ||
@@ -56,2 +62,8 @@ }, | ||
{ | ||
code: 'it("", function(done) { somethingAsync.then(undefined, function(err) { expect(err).toBe(true); done(); }) })', | ||
errors: [{ | ||
message: 'An "it" that uses an async method should handle failure (use "done.fail")' | ||
}] | ||
}, | ||
{ | ||
code: 'it("", function(done) { somethingAsync.then(f).then(function(res) { expect(res).toBe(true); done(); }) })', | ||
@@ -58,0 +70,0 @@ errors: [{ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
190030
2696