-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix comma-separated bbox value parsing (#160)
- Loading branch information
Phil Varner
authored
Feb 18, 2022
1 parent
f9d11c9
commit d114c48
Showing
2 changed files
with
34 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const test = require('ava') | ||
const api = require('../libs/api') | ||
|
||
test('extractBboxNull', (t) => { | ||
const params = {} | ||
const intersectsGeometry = api.extractBbox(params) | ||
t.falsy(intersectsGeometry, | ||
'Returns undefined when no bbox parameter') | ||
}) | ||
|
||
test('extractBbox JSON array', (t) => { | ||
const params = { bbox: [0, 0, 1, 1] } | ||
const intersectsGeometry = api.extractBbox(params) | ||
t.is(intersectsGeometry.coordinates[0].length, 5) | ||
t.is(intersectsGeometry.coordinates[0][0][0], 0) | ||
}) | ||
|
||
test('extractBbox comma-separated value', (t) => { | ||
const params = { bbox: '0,0,1,1' } | ||
const intersectsGeometry = api.extractBbox(params) | ||
t.is(intersectsGeometry.coordinates[0].length, 5) | ||
t.is(intersectsGeometry.coordinates[0][0][0], 0) | ||
}) | ||
|
||
test('extractBbox comma-separated value with whitespace', (t) => { | ||
const params = { bbox: '0 , 0.3 , 1.0,\t1' } | ||
const intersectsGeometry = api.extractBbox(params) | ||
t.is(intersectsGeometry.coordinates[0].length, 5) | ||
t.is(intersectsGeometry.coordinates[0][0][0], 0) | ||
}) |