Created
February 18, 2015 23:27
-
-
Save NicholasMurray/78f1c7be22715622f4ff to your computer and use it in GitHub Desktop.
AngularJS Geolocation Directive Jasmine Geolocation Not Available Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('Directive tests: geolocation ', function() { | |
| var $window, navigator; | |
| describe('when called on a browser that does not have geolocation available ', function() { | |
| beforeEach(module('geolocationApp')); | |
| beforeEach(inject(function($rootScope, $compile, _$window_) { | |
| element = angular.element('<geolocation class="geolocation"><p>This is a geolocation app</p></geolocation>'); | |
| scope = $rootScope; | |
| $window = _$window_; | |
| spyOn($window.navigator.geolocation, 'getCurrentPosition').and.callFake(function(error) { | |
| var error = {code: 1}; | |
| arguments[1](error); | |
| }); | |
| $compile(element)(scope); | |
| scope.$digest(); | |
| })); | |
| it("should display a message to inform the user", function() { | |
| expect(element.text()).toEqual('Your geolocation is not available'); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment