marker_spec.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* global google, waitsFor */
  2. describe('marker', function() {
  3. var elm, scope;
  4. /* mock Attr2Options, knowns as parser */
  5. var MockAttr2Options = function() {
  6. var hashFilter = function(hash) {
  7. var newHash = {};
  8. for (var key in hash) {
  9. if (hash[key].match(regexp)) {
  10. newHash[key] = hash[key];
  11. }
  12. };
  13. return newHash;
  14. };
  15. return {
  16. filter: function(attrs) {return attrs;},
  17. getOptions: function(attrs) {return attrs;},
  18. getControlOptions: function(attrs) {return hashFilter(attrs, /ControlOptions$/);},
  19. getEvents: function(attrs) {return hashFilter(attrs, /^on[A-E]/);}
  20. };
  21. };
  22. // load the marker code
  23. beforeEach(function() {
  24. module(function($provide) {
  25. $provide.value('Attr2Options', MockAttr2Options);
  26. });
  27. module('ngMap');
  28. inject(function($rootScope, $compile) {
  29. elm = angular.element(
  30. '<map center="[40.74, -74.18]">'+
  31. ' <marker position="[40.74, -74.18]" draggable="true"></marker>'+
  32. ' <marker position="[40.74, -74.18]" on-click="alert(1)"></marker>'+
  33. '</map>');
  34. scope = $rootScope;
  35. $compile(elm)(scope);
  36. scope.$digest();
  37. waitsFor(function() {
  38. return scope.map;
  39. });
  40. });
  41. });
  42. it('should set scope.markers with options ', function() {
  43. // scope.markers
  44. expect(Object.keys(scope.map.markers).length).toEqual(2);
  45. // options from attribute
  46. expect(scope.map.markers[0].draggable).toEqual(true);
  47. // contents from html
  48. });
  49. it('should set marker events', function() {
  50. //TODO: need to test marker events, but don't know don't know how to get events of a marker
  51. });
  52. it('should set marker observers', function() {
  53. //TODO: need to test marker observers
  54. });
  55. });