| 1 |
var tape = require("tape"), |
| 2 |
computeId = require("../lib/topojson/compute-id"); |
| 3 |
|
| 4 |
tape("compute-id by default, preserves the id of the feature", function(test) { |
| 5 |
test.deepEqual(computeId({ |
| 6 |
foo: { |
| 7 |
type: "Feature", |
| 8 |
id: "foo", |
| 9 |
geometry: { |
| 10 |
type: "LineString", |
| 11 |
coordinates: [0] |
| 12 |
} |
| 13 |
} |
| 14 |
}).foo, { |
| 15 |
type: "Feature", |
| 16 |
id: "foo", |
| 17 |
geometry: { |
| 18 |
type: "LineString", |
| 19 |
coordinates: [0] |
| 20 |
} |
| 21 |
}); |
| 22 |
test.end(); |
| 23 |
}); |
| 24 |
|
| 25 |
tape("compute-id observes the specified id function", function(test) { |
| 26 |
test.deepEqual(computeId({ |
| 27 |
foo: { |
| 28 |
type: "Feature", |
| 29 |
properties: {"name": "foo"}, |
| 30 |
geometry: { |
| 31 |
type: "LineString", |
| 32 |
coordinates: [0] |
| 33 |
} |
| 34 |
} |
| 35 |
}, function(feature) { |
| 36 |
return feature.properties.name; |
| 37 |
}).foo, { |
| 38 |
type: "Feature", |
| 39 |
id: "foo", |
| 40 |
properties: {"name": "foo"}, |
| 41 |
geometry: { |
| 42 |
type: "LineString", |
| 43 |
coordinates: [0] |
| 44 |
} |
| 45 |
}); |
| 46 |
test.end(); |
| 47 |
}); |
| 48 |
|