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 verifies that all Features within a FeatureCollection contain valid IDs that are all unique.
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. Therefore, this matcher rejects non-FeatureCollection objects.
This matcher takes an optional boolean argument, allowNulls. It will default to false. If set to true, the matcher ignores features that do not have an "id" member, or have the value of "id" explicitly set to null.
This test will fail if any of the features repeat a repeated ID, or if the "features" member is an empty array.
Description
GeoJSON Features have an optional ID member that can be any string or number. This matcher verifies that all Features within a FeatureCollection contain valid IDs that are all unique.
An "id" member on a non-feature object gets treated as a foreign member instead of an ID. Therefore, this matcher rejects non-FeatureCollection objects.
This matcher takes an optional boolean argument,
allowNulls
. It will default to false. If set to true, the matcher ignores features that do not have an "id" member, or have the value of "id" explicitly set tonull
.This test will fail if any of the features repeat a repeated ID, or if the "features" member is an empty array.
Example Matcher Usage
Passing Tests
Unique IDs
For both Strings, Numbers, and Combinations:
Only Some Have IDs, the Rest Null or Not Mentioned, allowNulls is True
For both Strings, Numbers, and Combinations:
null
null
FeatureCollection with No ID, allowNulls is True
null
.null
.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'
,Identical IDs
For both Strings, Numbers, and Combinations:
Only Some Have IDs, the Rest Null or Not Mentioned, allowNulls is False
For both Strings, Numbers, and Combinations:
null
FeatureCollection with Empty Features Array
Should fail because there are no features to check IDs on.
FeatureCollection with No ID, allowNulls is False
null
.null
.The text was updated successfully, but these errors were encountered: