shape_spec.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* global google, waitsFor */
  2. describe('shape', function() {
  3. var elm, scope;
  4. // load the marker code
  5. beforeEach(function() {
  6. module('ngMap');
  7. inject(function($rootScope, $compile) {
  8. elm = angular.element(
  9. '<map zoom="11" center="[40.74, -74.18]">'+
  10. ' <shape id="polyline" name="polyline" geodesic="true" stroke-color="#FF0000" stroke-opacity="1.0" stroke-weight="2"'+
  11. ' path="[[40.74,-74.18],[40.64,-74.10],[40.54,-74.05],[40.44,-74]]" />'+
  12. ' <shape id="polygon" name="polygon" stroke-color="#FF0000" stroke-opacity="1.0" stroke-weight="2"'+
  13. ' paths="[[40.74,-74.18],[40.64,-74.18],[40.84,-74.08],[40.74,-74.18]]" />'+
  14. ' <shape id="rectangle" name="rectangle" stroke-color="#FF0000" stroke-opacity="0.8" stroke-weight="2"'+
  15. ' bounds="[[40.74,-74.18], [40.78,-74.14]]" editable="true" />'+
  16. ' <shape id="circle" name="circle" stroke-color="#FF0000" stroke-opacity="0.8"stroke-weight="2" '+
  17. ' center="[40.70,-74.14]" radius="4000" editable="true" />'+
  18. ' <shape id="image" name="image" url="https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg"'+
  19. ' bounds="[[40.71,-74.22],[40.77,-74.12]]" opacity="0.7" clickable="true" />'+
  20. '</map>');
  21. scope = $rootScope;
  22. $compile(elm)(scope);
  23. scope.$digest();
  24. waitsFor(function() {
  25. return scope.map;
  26. });
  27. });
  28. });
  29. it('should set scope.shapes with options ', function() {
  30. // scope.shapes
  31. expect(Object.keys(scope.map.shapes).length).toEqual(5);
  32. // polyline
  33. expect(scope.map.shapes.polyline.geodesic).toBe(true);
  34. // polygon
  35. expect(scope.map.shapes.polygon.strokeColor).toEqual('#FF0000');
  36. // rectangle
  37. expect(scope.map.shapes.rectangle.editable).toBe(true);
  38. // circle
  39. expect(scope.map.shapes.circle.radius).toEqual(4000);
  40. // image
  41. expect(scope.map.shapes.image.getUrl()).toEqual("https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg");
  42. });
  43. it('should set shape events', function() {
  44. //TODO: should test events, but don't know how to get events of a shape
  45. });
  46. it('should set shape observers', function() {
  47. //TODO: need to test observers
  48. });
  49. });