feature($exceptionHandler): $exceptionHandler now supports var_args

This commit is contained in:
Misko Hevery
2011-12-14 09:28:16 +01:00
parent 517811764d
commit 84823b2eff
4 changed files with 34 additions and 14 deletions

View File

@@ -307,6 +307,9 @@ describe('ngMock', function() {
var $exceptionHandler = $exceptionHandlerProvider.$get();
$exceptionHandler('MyError');
expect($exceptionHandler.errors).toEqual(['MyError']);
$exceptionHandler('MyError', 'comment');
expect($exceptionHandler.errors[1]).toEqual(['MyError', 'comment']);
}));

View File

@@ -1,15 +1,24 @@
'use strict';
describe('$exceptionHandler', function() {
it('should log errors with single argument', function() {
module(function($provide){
$provide.service('$exceptionHandler', $ExceptionHandlerProvider);
});
inject(function($log, $exceptionHandler) {
$exceptionHandler('myError');
expect($log.error.logs.shift()).toEqual(['myError']);
});
});
it('should log errors', function() {
module(function($provide){
$provide.service('$exceptionHandler', $ExceptionHandlerProvider);
it('should log errors with multiple arguments', function() {
module(function($provide){
$provide.service('$exceptionHandler', $ExceptionHandlerProvider);
});
inject(function($log, $exceptionHandler) {
$exceptionHandler('myError', 'comment');
expect($log.error.logs.shift()).toEqual(['myError', 'comment']);
});
});
inject(function($log, $exceptionHandler) {
$exceptionHandler('myError');
expect($log.error.logs.shift()).toEqual(['myError']);
});
});
});