-
Notifications
You must be signed in to change notification settings - Fork 943
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #762 from Turfjs/tap-testing
Use tap as main testing suite
- Loading branch information
Showing
5 changed files
with
49 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
var test = require('tape'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var test = require('tape'); | ||
var {featureCollection} = require('@turf/helpers'); | ||
var along = require('./'); | ||
var featurecollection = require('@turf/helpers').featureCollection; | ||
|
||
var line = JSON.parse(fs.readFileSync(__dirname + '/test/fixtures/dc-line.geojson')); | ||
var line = JSON.parse(fs.readFileSync(path.join(__dirname, 'test', 'fixtures', 'dc-line.geojson'))); | ||
|
||
test('turf-along', function (t) { | ||
var pt1 = along(line, 1, 'miles'); | ||
var pt2 = along(line.geometry, 1.2, 'miles'); | ||
var pt3 = along(line, 1.4, 'miles'); | ||
var pt4 = along(line.geometry, 1.6, 'miles'); | ||
var pt5 = along(line, 1.8, 'miles'); | ||
var pt6 = along(line.geometry, 2, 'miles'); | ||
var pt7 = along(line, 100, 'miles'); | ||
var pt8 = along(line.geometry, 0, 'miles'); | ||
var fc = featurecollection([pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8]); | ||
var pt1 = along(line, 1, 'miles'); | ||
var pt2 = along(line.geometry, 1.2, 'miles'); | ||
var pt3 = along(line, 1.4, 'miles'); | ||
var pt4 = along(line.geometry, 1.6, 'miles'); | ||
var pt5 = along(line, 1.8, 'miles'); | ||
var pt6 = along(line.geometry, 2, 'miles'); | ||
var pt7 = along(line, 100, 'miles'); | ||
var pt8 = along(line.geometry, 0, 'miles'); | ||
var fc = featureCollection([pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8]); | ||
|
||
fc.features.forEach(function (f) { | ||
t.ok(f); | ||
t.equal(f.type, 'Feature'); | ||
t.equal(f.geometry.type, 'Point'); | ||
t.ok(f); | ||
t.equal(f.type, 'Feature'); | ||
t.equal(f.geometry.type, 'Point'); | ||
}); | ||
t.equal(fc.features.length, 8); | ||
t.equal(fc.features[7].geometry.coordinates[0], pt8.geometry.coordinates[0]); | ||
t.equal(fc.features[7].geometry.coordinates[1], pt8.geometry.coordinates[1]); | ||
|
||
t.end(); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
var test = require('tape'); | ||
var idw = require('./'); | ||
var fs = require('fs'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const test = require('tape'); | ||
const write = require('write-json-file'); | ||
const load = require('load-json-file'); | ||
const idw = require('./'); | ||
|
||
test('idw', function (t) { | ||
var testPoints = JSON.parse(fs.readFileSync('./test/in/data.geojson')); | ||
const directories = { | ||
in: path.join(__dirname, 'test', 'in') + path.sep, | ||
out: path.join(__dirname, 'test', 'out') + path.sep | ||
}; | ||
|
||
var idw1 = idw(testPoints, 'value', 0.5, 1, 'kilometers'); | ||
var idw2 = idw(testPoints, 'value', 0.5, 0.5, 'kilometers'); | ||
var idw3 = idw(testPoints, 'value', 2, 1, 'miles'); | ||
var idw4 = idw(testPoints, 'WRONGDataField', 0.5, 1, 'miles'); | ||
test('idw', t => { | ||
const testPoints = load.sync(directories.in + 'data.geojson'); | ||
|
||
t.ok(idw1.features.length); | ||
t.ok(idw2.features.length); | ||
t.ok(idw3.features.length); | ||
t.error(idw4); | ||
const idw1 = idw(testPoints, 'value', 0.5, 1, 'kilometers'); | ||
const idw2 = idw(testPoints, 'value', 0.5, 0.5, 'kilometers'); | ||
const idw3 = idw(testPoints, 'value', 2, 1, 'miles'); | ||
const idw4 = idw(testPoints, 'WRONGDataField', 0.5, 1, 'miles'); | ||
|
||
if (process.env.REGEN) { | ||
fs.writeFileSync(__dirname + '/test/out/idw1.geojson', JSON.stringify(idw1, null, 2)); | ||
fs.writeFileSync(__dirname + '/test/out/idw2.geojson', JSON.stringify(idw2, null, 2)); | ||
fs.writeFileSync(__dirname + '/test/out/idw3.geojson', JSON.stringify(idw3, null, 2)); | ||
} | ||
t.ok(idw1.features.length); | ||
t.ok(idw2.features.length); | ||
t.ok(idw3.features.length); | ||
t.error(idw4); | ||
|
||
t.end(); | ||
if (process.env.REGEN) { | ||
write.sync(directories.out + 'idw1.geojson', idw1); | ||
write.sync(directories.out + 'idw2.geojson', idw2); | ||
write.sync(directories.out + 'idw3.geojson', idw3); | ||
} | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters