|
| 1 | +require("../env"); |
| 2 | +require("../../d3"); |
| 3 | +require("../../d3.geo"); |
| 4 | + |
| 5 | +var vows = require("vows"), |
| 6 | + assert = require("assert"); |
| 7 | + |
| 8 | +var suite = vows.describe("d3.geo.equirectangular"); |
| 9 | + |
| 10 | +suite.addBatch({ |
| 11 | + "equirectangular": { |
| 12 | + topic: function() { |
| 13 | + return d3.geo.equirectangular(); |
| 14 | + }, |
| 15 | + |
| 16 | + "scale": { |
| 17 | + "defaults to 500": function(projection) { |
| 18 | + assert.equal(projection.scale(), 500); |
| 19 | + }, |
| 20 | + "is coerced to a number": function(projection) { |
| 21 | + assert.strictEqual(projection.scale("400"), projection); |
| 22 | + assert.strictEqual(projection.scale(), 400); |
| 23 | + projection.scale(500); |
| 24 | + } |
| 25 | + }, |
| 26 | + |
| 27 | + "translate": { |
| 28 | + "defaults to [480, 250]": function(projection) { |
| 29 | + assert.deepEqual(projection.translate(), [480, 250]); |
| 30 | + }, |
| 31 | + "is coerced to two numbers": function(projection) { |
| 32 | + assert.strictEqual(projection.translate(["23", "141"]), projection); |
| 33 | + assert.strictEqual(projection.translate()[0], 23); |
| 34 | + assert.strictEqual(projection.translate()[1], 141); |
| 35 | + projection.translate([480, 250]); |
| 36 | + } |
| 37 | + }, |
| 38 | + |
| 39 | + "of San Francisco, CA": { |
| 40 | + "is at location [-122.446, 37.767]": function(projection) { |
| 41 | + assert.inDelta(projection.invert([310, 198]), [-122.446, 37.767], .5); |
| 42 | + }, |
| 43 | + "is at point [310, 198]": function(projection) { |
| 44 | + assert.inDelta(projection([-122.446, 37.767]), [310, 198], .5); |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | +}); |
| 49 | + |
| 50 | +suite.export(module); |
0 commit comments