aboutsummaryrefslogtreecommitdiff
path: root/test/withinRange.js
diff options
context:
space:
mode:
authorAndrew Harvey <andrew@alantgeo.com.au>2021-07-05 12:01:04 +1000
committerAndrew Harvey <andrew@alantgeo.com.au>2021-07-05 12:01:04 +1000
commit0275d9e79da1f72044737fb0fbcaa4f136f09c6f (patch)
tree14dacdbde642c652dfc2625729e5d7ca518b6797 /test/withinRange.js
parentc1060fa51b8e9a1e0a9c1310acae10c2b3455a8d (diff)
update within range to accept comparing ranges
Diffstat (limited to 'test/withinRange.js')
-rw-r--r--test/withinRange.js97
1 files changed, 95 insertions, 2 deletions
diff --git a/test/withinRange.js b/test/withinRange.js
index 8d46eba..c2d37de 100644
--- a/test/withinRange.js
+++ b/test/withinRange.js
@@ -93,6 +93,75 @@ const rangeOutsideSub = {
}
}
+const B_withSuburb = {
+ "type": "Feature",
+ "properties": {
+ "addr:housenumber": "2",
+ "addr:street": "Main Street",
+ "addr:suburb": "Suburb A"
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+}
+const AC_withDifferentSuburb = {
+ "type": "Feature",
+ "properties": {
+ "addr:housenumber": "1-3",
+ "addr:street": "Main Street",
+ "addr:suburb": "Suburb B"
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+}
+
+const AD = {
+ "type": "Feature",
+ "properties": {
+ "addr:housenumber": "1-4",
+ "addr:street": "Main Street"
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+}
+const BC = {
+ "type": "Feature",
+ "properties": {
+ "addr:housenumber": "2-3",
+ "addr:street": "Main Street"
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+}
+const CE = {
+ "type": "Feature",
+ "properties": {
+ "addr:housenumber": "3-5",
+ "addr:street": "Main Street"
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+}
+const DE = {
+ "type": "Feature",
+ "properties": {
+ "addr:housenumber": "4-5",
+ "addr:street": "Main Street"
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+}
test('withinRange', t => {
t.same(
@@ -138,9 +207,33 @@ test('withinRange', t => {
)
t.same(
- withinRange(A, AC, { matchParity: true }),
+ withinRange(B_withSuburb, AC_withDifferentSuburb),
+ false,
+ 'by default checks suburbs match for within to pass'
+ )
+
+ t.same(
+ withinRange(B_withSuburb, AC_withDifferentSuburb, {
+ checkHigherOrderAddrKeys: false
+ }),
+ true,
+ 'within range when ignoring higher order addr keys'
+ )
+
+ t.same(
+ withinRange(BC, AD),
+ true,
+ 'range completely within range'
+ )
+ t.same(
+ withinRange(CE, AD),
+ true,
+ 'range overlapping within range'
+ )
+ t.same(
+ withinRange(DE, AD),
true,
- 'A within AC when matching parity'
+ 'range touching endpoints of range'
)
t.end()