You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GeoJSON Features have an optional ID member that can be any string or number.
If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of the Feature object with the name "id", and the value of this member is either a JSON string or number.
An "id" member on a non-feature object gets treated as a foreign member instead of an ID.
This matcher will take an optional argument of either a string, number, RegExp, or array of any combination of these. If no argument is provided, the matcher will check if the Feature object has an ID member of any value. Otherwise, it will check that the ID member exactly matches either the single input or any of the array values.
Description
GeoJSON Features have an optional ID member that can be any string or number.
An "id" member on a non-feature object gets treated as a foreign member instead of an ID.
This matcher will take an optional argument of either a
string
,number
,RegExp
, or array of any combination of these. If no argument is provided, the matcher will check if the Feature object has an ID member of any value. Otherwise, it will check that the ID member exactly matches either the single input or any of the array values.Valid GeoJSON Examples
Passing Tests
Numeric or String ID
Input:
0
-200
200
Infinity
-Infinity
'1'
'Test 123'
'Random ID String'
Empty string:
''
Using the matcher without an optional argument
Using the matcher with the input argument
Using the matcher with the input argument as a single element array
Using the matcher with the input argument as a RegExp
Using the matcher with the input argument as a single element array as a RegExp
Empty Array for Optional Argument
Input: 'Test ID', 3
Multiple Array Value Checking for Numeric ID
Only one element passes:
[1, 2, 3, 719]
['1', 719, '2', '3']
[/[0-9]+/, 2, 3, 'F1']
[755, /71[0-9]/]
More than one element passes:
[/72[0-9]/, /81[0-9]/, /71[0-9]/, /[0-9]+/]
Multiple Array Value Checking for String ID
Only one element passes:
['1', 719, '2', 3, 'Some String']
['A String ID', /Some/, 2]
[/SomeString/, /123/, /\bString\b/]
More than one element passes:
[/72[0-9]/, /\bString\b/, /71[0-9]/, /Some/]
Failing Tests
Invalid Inputs To Matcher
Rejects each of the following:
undefined
,null
,false
,true
,0
{ someProp: 'I am not GeoJSON', id: 4 }
''
,'Random Feature',
Valid Feature Does Not Have ID
Invalid Feature Provided
Invalid features should throw the toBeFeature errors instead of new ones here.
Invalid Inputs To Optional Argument
Rejects when the optional ID to check is
undefined
,null
,false
,true
{ someProp: 'I am not GeoJSON', id: 4 }
{}
NaN
Rejects when ID Does Not Match Optional Input Value
The text was updated successfully, but these errors were encountered: