Skip to content

Commit

Permalink
feat(fake): use geo tools helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Dec 16, 2019
1 parent 2bfbf1c commit a856635
Showing 1 changed file with 17 additions and 50 deletions.
67 changes: 17 additions & 50 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ const {
isMultiPoint,
isMultiLineString,
isMultiPolygon,
isGeometryCollection
isGeometryCollection,
randomPoint,
randomLineString,
randomPolygon,
randomMultiPoint,
randomMultiLineString,
randomMultiPolygon,
randomGeometry,
randomGeometryCollection,
} = geojson;


Expand Down Expand Up @@ -72,20 +80,7 @@ exports.Geometry = {
validator: isGeometry,
message: '{PATH} is not a valid GeoJSON Geometry'
},
fake: {
generator: function fakeGeometryGenerator() {
const fakes = [
exports.randomPoint,
exports.randomLineString,
exports.randomPolygon,
exports.randomMultiPoint,
exports.randomMultiLineString,
exports.randomMultiPolygon
];
const fake = fakes[(Math.floor(Math.random() * fakes.length))];
return fake();
}
}
fake: () => randomGeometry()
};


Expand All @@ -98,11 +93,7 @@ exports.Point = {
validator: isPoint,
message: '{PATH} is not a valid GeoJSON Point'
},
fake: {
generator: function fakePointGenerator() {
return exports.randomPoint();
}
}
fake: () => randomPoint()
};


Expand All @@ -115,11 +106,7 @@ exports.LineString = {
validator: isLineString,
message: '{PATH} is not a valid GeoJSON LineString'
},
fake: {
generator: function fakeLineStringGenerator() {
return exports.randomLineString();
}
}
fake: () => randomLineString()
};


Expand All @@ -132,11 +119,7 @@ exports.Polygon = {
validator: isPolygon,
message: '{PATH} is not a valid GeoJSON Polygon'
},
fake: {
generator: function fakePolygonGenerator() {
return exports.randomPolygon();
}
}
fake: () => randomPolygon()
};


Expand All @@ -149,11 +132,7 @@ exports.MultiPoint = {
validator: isMultiPoint,
message: '{PATH} is not a valid GeoJSON MultiPoint'
},
fake: {
generator: function fakeMultiPointGenerator() {
return exports.randomMultiPoint();
}
}
fake: () => randomMultiPoint()
};


Expand All @@ -166,11 +145,7 @@ exports.MultiLineString = {
validator: isMultiLineString,
message: '{PATH} is not a valid GeoJSON MultiLineString'
},
fake: {
generator: function fakeMultiLineStringGenerator() {
return exports.randomMultiLineString();
}
}
fake: () => randomMultiLineString()
};


Expand All @@ -183,11 +158,7 @@ exports.MultiPolygon = {
validator: isMultiPolygon,
message: '{PATH} is not a valid GeoJSON MultiPolygon'
},
fake: {
generator: function fakeMultiPolygonGenerator() {
return exports.randomMultiPolygon();
}
}
fake: () => randomMultiPolygon()
};


Expand All @@ -200,9 +171,5 @@ exports.GeometryCollection = {
validator: isGeometryCollection,
message: '{PATH} is not a valid GeoJSON GeometryCollection'
},
fake: {
generator: function fakeMultiPolygonGenerator() {
return exports.randomGeometryCollection();
}
}
fake: () => randomGeometryCollection()
};

0 comments on commit a856635

Please sign in to comment.