Podcast/lib/angular/docs/partials/api/ngMock.$exceptionHandler.html
2013-08-21 19:46:51 +02:00

33 lines
1.6 KiB
HTML
Executable file

<a href="http://github.com/angular/angular.js/tree/v1.2.0rc1/src/ngMock/angular-mocks.js#L213" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ngMock/angular-mocks.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">$exceptionHandler</code>
<div><span class="hint">service in module <code ng:non-bindable="">ngMock</code>
</span>
</div>
</h1>
<div><h2 id="Description">Description</h2>
<div class="description"><div class="ngmock-exceptionhandler-page"><p>Mock implementation of <a href="api/ng.$exceptionHandler"><code>ng.$exceptionHandler</code></a> that rethrows or logs errors passed
into it. See <a href="api/ngMock.$exceptionHandlerProvider">$exceptionHandlerProvider</a> for configuration
information.</p>
<pre class="prettyprint linenums">
describe('$exceptionHandlerProvider', function() {
it('should capture log messages and exceptions', function() {
module(function($exceptionHandlerProvider) {
$exceptionHandlerProvider.mode('log');
});
inject(function($log, $exceptionHandler, $timeout) {
$timeout(function() { $log.log(1); });
$timeout(function() { $log.log(2); throw 'banana peel'; });
$timeout(function() { $log.log(3); });
expect($exceptionHandler.errors).toEqual([]);
expect($log.assertEmpty());
$timeout.flush();
expect($exceptionHandler.errors).toEqual(['banana peel']);
expect($log.log.logs).toEqual([[1], [2], [3]]);
});
});
});
</pre>
</div></div>
</div>