Browse files

Test Extent. Fixes #91

  • Loading branch information...
1 parent f612ba7 commit b265dde102eb1a71b26030c82626c4cc79cb5063 @tmcw tmcw committed Feb 1, 2012
Showing with 42 additions and 0 deletions.
  1. +1 −0 test/browser/index.html
  2. +41 −0 test/browser/spec/Extent.js
View
1 test/browser/index.html
@@ -20,6 +20,7 @@
<script type="text/javascript" src="spec/Map.js"></script>
<script type="text/javascript" src="spec/Layer.js"></script>
<script type="text/javascript" src="spec/Location.js"></script>
+ <script type="text/javascript" src="spec/Extent.js"></script>
<script type="text/javascript" src="spec/DragHandler.js"></script>
<script type="text/javascript" src="spec/MouseWheelHandler.js"></script>
<script type="text/javascript" src="spec/DoubleClickHandler.js"></script>
View
41 test/browser/spec/Extent.js
@@ -0,0 +1,41 @@
+describe('Extent', function() {
+ var ext;
+
+ function Receiver() { }
+ Receiver.prototype.receive = function() { };
+
+ beforeEach(function() {
+ ext = new MM.Extent(-10, -10, 10, 10);
+
+ });
+
+ it('properly initializes its sides', function() {
+ expect(ext.west).toEqual(-10);
+ expect(ext.south).toEqual(-10);
+ expect(ext.north).toEqual(10);
+ expect(ext.east).toEqual(10);
+ });
+
+ it('expands to fit a location', function() {
+ ext.encloseLocation(new MM.Location(-40, -40));
+ expect(ext.west).toEqual(-40);
+ expect(ext.south).toEqual(-40);
+ });
+
+ it('expands to fit locations', function() {
+ ext.encloseLocations([
+ new MM.Location(-40, -40),
+ new MM.Location(40, 40)
+ ]);
+ expect(ext.west).toEqual(-40);
+ expect(ext.east).toEqual(40);
+ expect(ext.south).toEqual(-40);
+ expect(ext.north).toEqual(40);
+ });
+
+ it('knows when it contains a location', function() {
+ expect(ext.containsLocation(new MM.Location(0, 0))).toEqual(true);
+ expect(ext.containsLocation(new MM.Location(0, 90))).toEqual(false);
+ });
+
+});

0 comments on commit b265dde

Please sign in to comment.