diff options
| author | Brian Ford | 2014-03-03 12:30:33 -0800 |
|---|---|---|
| committer | Brian Ford | 2014-03-03 12:30:33 -0800 |
| commit | 220e7bf2d448fd80d98d5c2f3cfac3902433df8f (patch) | |
| tree | 9b46c834e26a813705a6c39a418f7cef51f6e45b /docs/content/guide/dev_guide.services.testing_services.ngdoc | |
| parent | 8d6eed21d219e459331a9f08fd46f8c67a9553da (diff) | |
| download | angular.js-220e7bf2d448fd80d98d5c2f3cfac3902433df8f.tar.bz2 | |
docs(guide/services): rewrite services documentation
Diffstat (limited to 'docs/content/guide/dev_guide.services.testing_services.ngdoc')
| -rw-r--r-- | docs/content/guide/dev_guide.services.testing_services.ngdoc | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/docs/content/guide/dev_guide.services.testing_services.ngdoc b/docs/content/guide/dev_guide.services.testing_services.ngdoc deleted file mode 100644 index 67a1635d..00000000 --- a/docs/content/guide/dev_guide.services.testing_services.ngdoc +++ /dev/null @@ -1,62 +0,0 @@ -@ngdoc overview -@name Angular Services: Testing Angular Services -@description - -The following is a unit test for the 'notify' service in the 'Dependencies' example in {@link -dev_guide.services.creating_services Creating Angular Services}. The unit test example uses Jasmine -spy (mock) instead of a real browser alert. - -```js -var mock, notify; - -beforeEach(function() { - mock = {alert: jasmine.createSpy()}; - - module(function($provide) { - $provide.value('$window', mock); - }); - - inject(function($injector) { - notify = $injector.get('notify'); - }); -}); - -it('should not alert first two notifications', function() { - notify('one'); - notify('two'); - - expect(mock.alert).not.toHaveBeenCalled(); -}); - -it('should alert all after third notification', function() { - notify('one'); - notify('two'); - notify('three'); - - expect(mock.alert).toHaveBeenCalledWith("one\ntwo\nthree"); -}); - -it('should clear messages after alert', function() { - notify('one'); - notify('two'); - notify('third'); - notify('more'); - notify('two'); - notify('third'); - - expect(mock.alert.callCount).toEqual(2); - expect(mock.alert.mostRecentCall.args).toEqual(["more\ntwo\nthird"]); -}); -``` - - -## Related Topics - -* {@link dev_guide.services.understanding_services Understanding Angular Services} -* {@link dev_guide.services.creating_services Creating Angular Services} -* {@link dev_guide.services.managing_dependencies Managing Service Dependencies} -* {@link dev_guide.services.injecting_controllers Injecting Services Into Controllers} - -## Related API - -* {@link ./ng Angular Service API} |
