Commit 75b58fe4 authored by Kaitlyn's avatar Kaitlyn
Browse files

Got AstroMap test setup.

parent a92028bb
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
import AstroProj from "./AstroProj";
import LayerCollection from "./LayerCollection";
import "leaflet-fullscreen";
// import "leaflet-fullscreen";
import L from "leaflet";
/**
 * @class AstroMap
 * @aka L.Map.AstroMap
@@ -177,5 +178,15 @@ export default L.Map.AstroMap = L.Map.extend({
   */
  currentLayer: function() {
    return this._currentLayer;
  },

  /**
   * @function AstroMap.prototype.radii
   * @description Returns the a and c radii of the target.
   *
   * @return {Dictionary} Radii of target in form {'a': . 'c': }.
   */
  radii: function() {
    return this._radii;
  }
});
+3 −10
Original line number Diff line number Diff line
import { MY_JSON_MAPS } from "./layers";
import "./MousePosition";

/**
 * @class AstroMath
@@ -104,19 +103,13 @@ export default class AstroMath {
      convertedLon -= 180;
    }


    if (convertedLon < 0) {
      if (projection == "EPSG:4326")
      {
      if (projection == "EPSG:4326") {
        convertedLon += 360;
      }
      else
      {
      } else {
        convertedLon += 180;
      }
    }
    else if (projection != "EPSG:4326")
    {
    } else if (projection != "EPSG:4326") {
      convertedLon += 180;
    }

+30 −31
Original line number Diff line number Diff line
import { MY_JSON_MAPS } from "./layers";
import $ from "jquery";
import L from "leaflet";

/**
 * @class LayerCollection
@@ -11,7 +12,6 @@ import $ from "jquery";
 * for quick and easy use in the AstroMap class.
 */
export default L.LayerCollection = L.Class.extend({

  /**
   * @function LayerCollection.prototype.initialize
   * @description Constructor that creates the layers.
@@ -123,7 +123,6 @@ export default L.LayerCollection = L.Class.extend({
    // Only add feature names to cylindrical
    if (this._projName == "cylindrical") {
      this._wfsLayer = new L.GeoJSON(null, {

        /**
         * @function LayerCollection.prototype.onEachFeature
         * @description Select each feature.
+18 −19
Original line number Diff line number Diff line
import AstroMath from "./AstroMath";
import "leaflet";
import L from "leaflet";

/**
 * @class MousePosition
 * @aka L.Control.AstroMousePosition
@@ -119,8 +121,7 @@ export default L.Control.MousePosition = L.Control.extend({
    let { lng } = e.latlng;
    let { lat } = e.latlng;

    if (lat <= 90 && lat >= -90)
    {
    if (lat <= 90 && lat >= -90) {
      lng = L.Util.wrapNum(lng, [-180.0, 180.0]);

      if (!this.isLatTypeOcentric) {
@@ -145,9 +146,7 @@ export default L.Control.MousePosition = L.Control.extend({
      //const prefixAndValue = `${this.options.prefix}${value}`;
      this.lonDisplayElement.innerHTML = lng;
      this.latDisplayElement.innerHTML = lat;
    }
    else
    {
    } else {
      this.lonDisplayElement.innerHTML = "---.---";
      this.latDisplayElement.innerHTML = "---.---";
    }
+49 −0
Original line number Diff line number Diff line
import "jsdom-global/register";
import jsdom from "mocha-jsdom";
import AstroMap from "../src/js/AstroMap";
import { assert, expect } from "chai";

beforeEach(function() {
  // Setup map div
  document.body.innerHTML = '<div id="map"></div>';
});

afterEach(function() {
  // Setup map div
  document.body.innerHTML = "";
});

describe("AstroMap", function() {
  it("should instantiate an object and set defaults", function() {
    let target = "Mars";
    let testMap = new AstroMap("map", target, {});
    expect(testMap).to.be.an("Object");
    expect(testMap.target() == target);

    let mapOptions = testMap.options;
    expect(testMap.options.center == [0, 0]);
    expect(testMap.options.zoom == 1);
    expect(testMap.options.maxZoom == 8);
    expect(testMap.options.attributionControl == false);
    expect(testMap.options.fullScreenControl == true);
  });

  it("should instantiate a map with all caps target", function() {
    let target = "MARS";
    let testMap = new AstroMap("map", target);
    expect(testMap).to.be.an("Object");
    expect(testMap.target() == target);
  });

  it("should instantiate a map with all lowercase target", function() {
    let target = "mars";
    let testMap = new AstroMap("map", target);
    expect(testMap).to.be.an("Object");
    expect(testMap.target() == target);
  });

  // // Move JSON parsing to map
  // it("should throw an exception with an invalid target", function() {
  //   let testMap = new AstroMap("map", "invalidTarget");
  // });
});