d3/test/geo/path-test.js

50 строки
1.5 KiB
JavaScript
Исходник Обычный вид История

require("../env");
var vows = require("vows"),
assert = require("assert");
var suite = vows.describe("d3.geo.path");
suite.addBatch({
"path": {
topic: d3.geo.path,
"returns null when passed a null object": function(path) {
assert.isNull(path(null));
},
"projection": {
"returns the current projection when called with no arguments": function() {
var path = d3.geo.path(), projection = d3.geo.albers();
path.projection(projection);
assert.strictEqual(path.projection(), projection);
}
},
"pointRadius": {
"returns the current point radius when called with no arguments": function() {
var path = d3.geo.path(), radius = function() { return 5; };
assert.strictEqual(path.pointRadius(), 4.5);
assert.strictEqual(path.pointRadius(radius).pointRadius(), radius);
}
},
"Polygon": function(path) {
assert.equal(path({
type: "Feature",
geometry: {
type: "Polygon",
coordinates: [[[-63.03, 18.02], [-63.14, 18.06], [-63.01, 18.07], [-63.03, 18.02]]]
},
}), "M984.5652086349427,468.99159422596244L981.8396467935554,467.9114977057422L985.0785139575695,467.688661596079Z");
},
"bogus type name": function(path) {
assert.isNull(path({
type: "Feature",
geometry: {
type: "__proto__",
coordinates: [[[-63.03, 18.02], [-63.14, 18.06], [-63.01, 18.07], [-63.03, 18.02]]]
},
}));
}
}
});
suite.export(module);