diff options
author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-07 22:00:39 +1000 |
---|---|---|
committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-07 22:00:39 +1000 |
commit | 8581d5182b9b0b126b6cf690e40740ebf5aa1c75 (patch) | |
tree | eb5ee244f0931a35989dbfb60e05696f2835cf42 /test/withinRange.js | |
parent | bf16ee83f422c06d0f49e09d53de843e128b0dc8 (diff) |
reduce numbers within a range duplication
Diffstat (limited to 'test/withinRange.js')
-rw-r--r-- | test/withinRange.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/test/withinRange.js b/test/withinRange.js new file mode 100644 index 0000000..1158c20 --- /dev/null +++ b/test/withinRange.js @@ -0,0 +1,107 @@ +const test = require('tape') + +const withinRange = require('../lib/withinRange.js') + +const A = { + "type": "Feature", + "properties": { + "addr:housenumber": "1", + "addr:street": "Main Street" + }, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } +} +const B = { + "type": "Feature", + "properties": { + "addr:housenumber": "2", + "addr:street": "Main Street" + }, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } +} +const C = { + "type": "Feature", + "properties": { + "addr:housenumber": "3", + "addr:street": "Main Street" + }, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } +} +const AB = { + "type": "Feature", + "properties": { + "addr:housenumber": "1-2", + "addr:street": "Main Street" + }, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } +} +const AC = { + "type": "Feature", + "properties": { + "addr:housenumber": "1-3", + "addr:street": "Main Street" + }, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } +} + +const AC_2 = { + "type": "Feature", + "properties": { + "addr:housenumber": "1-3", + "addr:street": "Second Street" + }, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } +} + + +test('withinRange', t => { + t.same( + withinRange(A, AB), + true, + 'A within AB' + ) + t.same( + withinRange(A, AC), + true, + 'A within AC' + ) + t.same( + withinRange(B, AB), + true, + 'B within AB' + ) + t.same( + withinRange(B, AC), + true, + 'B within AC' + ) + t.same( + withinRange(C, AB), + false, + 'C not within AB' + ) + t.same( + withinRange(A, AC_2), + false, + 'A Main Street not within AC Secondary Street' + ) + + t.end() +}) |