angular-async-validator
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "angular-async-validator", | ||
"version": "0.2.1", | ||
"homepage": "https://github.com/pocesar/angular-async-validator", | ||
@@ -5,0 +4,0 @@ "authors": [ |
{ | ||
"name": "angular-async-validator", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "This module enables you to register your own validation rules, or overwrite existing ones. Makes every validation 'promise based', so it can deal with both synchronous and asynchronous validations. Also, sometimes you want validate an entire form when a model changes, which currently there are no good ways to do this, hence this module, because validation and form manipulation in Angular 1.x is a pain by itself.", | ||
@@ -36,2 +36,5 @@ "main": "index.js", | ||
}, | ||
"dependencies": { | ||
"angular":">=1.3 <2" | ||
}, | ||
"author": "Paulo Cesar <https://github.com/pocesar>", | ||
@@ -38,0 +41,0 @@ "license": "MIT", |
@@ -117,2 +117,7 @@ describe('AsyncValidator', function () { | ||
}, { silentRejection: false }); | ||
Provider.register('rejectionError', function(){ | ||
return function(){ | ||
return $q.reject(new Error('oh my')); | ||
}; | ||
}, { silentRejection: false }); | ||
Provider.register('forcereject', function(){ | ||
@@ -122,2 +127,7 @@ return function(){ | ||
}; | ||
}, { silentRejection: false }); | ||
Provider.register('forcesilencereject', function(){ | ||
return function(){ | ||
return $q.reject('ok'); | ||
}; | ||
}); | ||
@@ -130,3 +140,4 @@ | ||
sinon.stub($exceptionHandler, 'fn', function(err){ | ||
if ($exceptionHandler.fn.callCount > 2) { | ||
if (err.name === 'AssertionError') { | ||
// always throw assertionerrors, they are expected | ||
throw err; | ||
@@ -169,4 +180,12 @@ } | ||
.catch(function(err){ | ||
expect($exceptionHandler.fn.callCount).to.equal(2); | ||
expect(err).to.equal('ok'); | ||
return AsyncValidator.run('forcesilencereject','test'); | ||
}) | ||
.catch(function(err){ | ||
expect(err).to.match(/ok/); | ||
return AsyncValidator.run('rejectionError'); | ||
}) | ||
.catch(function(err){ | ||
expect($exceptionHandler.fn.callCount).to.equal(4); | ||
expect($exceptionHandler.fn.args[2][0]).to.match(/ok/); | ||
expect($exceptionHandler.fn.args[3][0]).to.match(/oh my/); | ||
done(); | ||
@@ -356,3 +375,7 @@ }); | ||
sinon.stub($exceptionHandler, 'fn', function(){}); | ||
sinon.stub($exceptionHandler, 'fn', function(err){ | ||
if (err.name === 'AssertionError') { | ||
throw err; | ||
} | ||
}); | ||
@@ -383,3 +406,7 @@ var | ||
sinon.stub($exceptionHandler, 'fn', function(){}); | ||
sinon.stub($exceptionHandler, 'fn', function(err){ | ||
if (err.name === 'AssertionError') { | ||
throw err; | ||
} | ||
}); | ||
@@ -386,0 +413,0 @@ var |
73939
1357
1
+ Addedangular@>=1.3 <2
+ Addedangular@1.8.3(transitive)