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. This matcher only validates IDs with type number. To check for either string only, use toHaveStringID. To check for either string or number, use toHaveID.
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 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 with type number. Otherwise, it will check that the ID member exactly matches either the single input or any of the array values.
Passing a string type to SearchID will not pass the test, even if the ID exactly matches.
Description
GeoJSON Features have an optional ID member that can be any string or number. This matcher only validates IDs with type
number
. To check for eitherstring
only, use toHaveStringID. To check for eitherstring
ornumber
, use toHaveID.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
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 with typenumber
. Otherwise, it will check that the ID member exactly matches either the single input or any of the array values.Passing a
string
type to SearchID will not pass the test, even if the ID exactly matches.Valid GeoJSON Examples
Example Matcher Usage
Passing Tests
Numeric IDs
Input:
1
0
5000
-Infinity
Infinity
Empty Array for Optional Argument
Multiple Array Value Checking for Numeric ID
Only one element passes:
[1, 719, 0, 123]
[-5, /7/, 15]
[/719/, /123/, /\bString\b/]
More than one element passes:
[/72[0-9]/, /\bString\b/, /71[0-9]/, 719]
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'
,Otherwise Valid String IDs Fail
Input:
'1'
'Test 123'
'Random ID String'
''
Invalid Inputs To Optional Argument
Rejects when the optional ID to check is
'Some String'
,''
,'1'
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: