Skip to content

Commit

Permalink
Add unit tests for new map models
Browse files Browse the repository at this point in the history
Issue #2189
  • Loading branch information
robyngit committed Sep 6, 2023
1 parent 24c8050 commit 0668c24
Show file tree
Hide file tree
Showing 4 changed files with 497 additions and 8 deletions.
61 changes: 61 additions & 0 deletions test/js/specs/unit/models/maps/GeoPoint.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
define([
"../../../../../../../../src/js/models/maps/GeoPoint",
], function (GeoPoint) {
// Configure the Chai assertion library
var should = chai.should();
var expect = chai.expect;

describe("GeoPoint Test Suite", function () {
/* Set up */
beforeEach(function () {});

/* Tear down */
afterEach(function () {});

describe("Initialization", function () {
it("should create a GeoPoint instance", function () {
new GeoPoint().should.be.instanceof(GeoPoint);
});
});

describe("Validation", function () {
it("should validate a valid GeoPoint", function () {
var point = new GeoPoint({
latitude: 0,
longitude: 0,
height: 0
});
point.isValid().should.be.true;
});

it("should invalidate a GeoPoint with an invalid latitude", function () {
var point = new GeoPoint({
latitude: 100,
longitude: 0,
height: 0
});
point.isValid().should.be.false;
});

it("should invalidate a GeoPoint with an invalid longitude", function () {
var point = new GeoPoint({
latitude: 0,
longitude: 200,
height: 0
});
point.isValid().should.be.false;
});

it("should invalidate a GeoPoint with an invalid height", function () {
var point = new GeoPoint({
latitude: 0,
longitude: 0,
height: "foo"
});
point.isValid().should.be.false;
});
});


});
});
47 changes: 47 additions & 0 deletions test/js/specs/unit/models/maps/GeoScale.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
define([
"../../../../../../../../src/js/models/maps/GeoScale",
], function (GeoScale) {
// Configure the Chai assertion library
var should = chai.should();
var expect = chai.expect;

describe("GeoScale Test Suite", function () {
/* Set up */
beforeEach(function () {});

/* Tear down */
afterEach(function () {});

describe("Initialization", function () {
it("should create a GeoScale instance", function () {
new GeoScale().should.be.instanceof(GeoScale);
});
});

describe("Validation", function () {
it("should validate a valid GeoScale", function () {
var scale = new GeoScale({
pixel: 1,
meters: 1
});
scale.isValid().should.be.true;
});

it("should invalidate a GeoScale with an invalid pixel scale", function () {
var scale = new GeoScale({
pixel: -1,
meters: 1
});
scale.isValid().should.be.false;
});

it("should invalidate a GeoScale with an invalid meters scale", function () {
var scale = new GeoScale({
pixel: 1,
meters: -1
});
scale.isValid().should.be.false;
});
});
});
});
Loading

0 comments on commit 0668c24

Please sign in to comment.