Created
February 18, 2015 23:27
-
-
Save NicholasMurray/baeb1de0d4fcffe2fbe9 to your computer and use it in GitHub Desktop.
AngularJS Geolocation Directive Jasmine Geolocation 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 has 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() { | |
| var position = { coords: { latitude: 12.3, longitude: -32.1 } }; | |
| arguments[0](position); | |
| }); | |
| $compile(element)(scope); | |
| scope.$digest(); | |
| })); | |
| it("should display the current latitude and longitude", function() { | |
| expect(element.find('#latitude').text()).toEqual('12.3'); | |
| expect(element.find('#longitude').text()).toEqual('-32.1'); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment