Skip to content

Commit

Permalink
feat(toHaveMinGeometryCount): add new matcher
Browse files Browse the repository at this point in the history
Verifies a valid GeoJSON GeometryCollection has more than or equal to a specified number of
geometries.

Resolves: #45
  • Loading branch information
M-Scott-Lassiter committed Jun 11, 2022
1 parent 6a31a48 commit c71c21a
Show file tree
Hide file tree
Showing 67 changed files with 1,481 additions and 7 deletions.
1 change: 1 addition & 0 deletions .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const allMatchers = [
{ name: 'toBeValidGeoJSON' },
{ name: 'toHaveGeometryCount' },
{ name: 'toHaveID' },
{ name: 'toHaveMinGeometryCount' },
{ name: 'toHaveNumericID' },
{ name: 'toHaveStringID' }
]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ Functional matchers assess more generic attributes and qualities and many accept
- [toBePointGeometry](https://m-scott-lassiter.github.io/jest-geojson/Core.Geometries.html#.pointGeometry)
- [toBePolygonGeometry](https://m-scott-lassiter.github.io/jest-geojson/Matchers.Geometries.html#.toBePolygonGeometry)
- [toBePolygonWithHole](https://m-scott-lassiter.github.io/jest-geojson/Matchers.Geometries.html#.toBePolygonWithHole)
- [toHaveGeometeyCount](https://m-scott-lassiter.github.io/jest-geojson/Matchers.Geometries.html#.toHaveGeometeyCount)
- [toHaveGeometryCount](https://m-scott-lassiter.github.io/jest-geojson/Matchers.Geometries.html#.toHaveGeometryCount)
- [toHaveMinGeometryCount](https://m-scott-lassiter.github.io/jest-geojson/Matchers.Geometries.html#.toHaveMinGeometryCount)

---

_Future_

- [ ] toHaveMinGeometryCount
- [ ] toHaveMaxGeometeyCount

## Features
Expand Down
5 changes: 5 additions & 0 deletions docs/Core.BoundingBoxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Core.Coordinates.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Core.FeatureCollections.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Core.Features.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Core.Geometries.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Core.Utilities.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Core.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Matchers.BoundingBoxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Matchers.Coordinates.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Matchers.FeatureCollections.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Matchers.Features.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/Matchers.Functional.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
154 changes: 154 additions & 0 deletions docs/Matchers.Geometries.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -1660,6 +1665,155 @@ <h5>Parameters:</h5>
</tr>
</tbody>
</table>

<h4 class="name" id=".toHaveMinGeometryCount">
<span class="type-signature">(static) </span>toHaveMinGeometryCount<span
class="signature"
>(geometryObject, MinCount<span class="signature-attributes">opt</span
>)</span
><span class="type-signature"></span>
</h4>

<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="matchers_geometries_toHaveMinGeometryCount.js.html"
>matchers/geometries/toHaveMinGeometryCount.js</a
>,
<a
href="matchers_geometries_toHaveMinGeometryCount.js.html#line74"
>line 74</a
>
</li>
</ul>
</dd>

<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li>
<a
href="https://github.com/M-Scott-Lassiter/jest-geojson/issues/45"
>https://github.com/M-Scott-Lassiter/jest-geojson/issues/45</a
>
</li>
</ul>
</dd>
</dl>

<div class="description usertext">
Verifies a valid GeoJSON GeometryCollection has more than or equal to a
specified number of geometries. If omitting MinCount, it passes if at least
one geometry object is contained in "geometries". Will fail if MinCount is
not a number or less than zero. Nested GeometryCollections are only counted
as a single geometry object.
</div>

<h5>Examples</h5>

<pre class="prettyprint"><code>const testCollection = {
"type": "GeometryCollection",
"geometries": [{
"type": "Point",
"coordinates": [100.0, 0.0]
}, {
"type": "LineString",
"coordinates": [
[101.0, 0.0],
[102.0, 1.0]
]
}, {
"type": "Polygon",
"coordinates": [
[
[102.0, 2.0],
[103.0, 2.0],
[103.0, 3.0],
[102.0, 3.0],
[102.0, 2.0]
]
]
}, {
"type": "Point",
"coordinates": [150.0, 73.0]
}]
}

test('GeometryCollection has minimum geometry count', () => {
expect(testCollection).toHaveMinGeometryCount()
expect(testCollection).toHaveMinGeometryCount(4)
})</code></pre>

<pre class="prettyprint"><code>const emptyCollection = {
"type": "GeometryCollection",
"geometries": []
}
const polygon = {
type: 'Polygon',
coordinates: [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
}

test('Object is not a GeometryCollection or does not have minimum geometry count', () => {
expect(testCollection).not.toHaveMinGeometryCount(5)
expect(emptyCollection).not.toHaveMinGeometryCount()
expect(polygon).not.toHaveMinGeometryCount(1)
})</code></pre>

<h5>Parameters:</h5>

<table class="params">
<thead>
<tr>
<th>Name</th>

<th>Type</th>

<th>Attributes</th>

<th class="last">Description</th>
</tr>
</thead>

<tbody>
<tr>
<td class="name"><code>geometryObject</code></td>

<td class="type">
<span class="param-type">object</span>
</td>

<td class="attributes"></td>

<td class="description last">
A GeoJSON GeometryCollection object
</td>
</tr>

<tr>
<td class="name"><code>MinCount</code></td>

<td class="type">
<span class="param-type">number</span>
</td>

<td class="attributes">&lt;optional><br /></td>

<td class="description last">
Minimum geometry object count to check for. Omit to assume 1.
</td>
</tr>
</tbody>
</table>
</article>
</section>
</div>
Expand Down
5 changes: 5 additions & 0 deletions docs/Matchers.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/core_boundingBoxes_valid2DBoundingBox.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/core_boundingBoxes_valid3DBoundingBox.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/core_boundingBoxes_validBoundingBox.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions docs/core_coordinates_valid2DCoordinate.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ <h3>Namespaces</h3>
>toHaveGeometryCount</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toHaveMinGeometryCount"
>toHaveMinGeometryCount</a
>
</li>
</ul>
</li>
</ul>
Expand Down
Loading

0 comments on commit c71c21a

Please sign in to comment.