Skip to content

Commit

Permalink
feat(toBeValidGeoJSON): add new matcher
Browse files Browse the repository at this point in the history
This tests an object to see if it meets validation criteria for any of the seven GeoJSON Geometry
types, Features, or FeatureCollections.
Creates new setup script and entry point, the
test:functional script, updates most of the other test suites to include this matcher as a piggy
back.
Reorganizes utilities.
Updates documentation accordingly.

Resolves: #26
  • Loading branch information
M-Scott-Lassiter committed Jun 4, 2022
1 parent 93eab42 commit bf67420
Show file tree
Hide file tree
Showing 89 changed files with 3,169 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const allMatchers = [
{ name: 'toBeMultiPointGeometry' },
{ name: 'toBeMultiPolygonGeometry' },
{ name: 'toBePointGeometry' },
{ name: 'toBePolygonGeometry' }
{ name: 'toBePolygonGeometry' },
{ name: 'toBeValidGeoJSON' }
]

const documentationScopes = [
Expand Down
37 changes: 13 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,44 +103,31 @@ After installing, you should [run the build script](#building) to verify everyth

### Project Structure

The `src` folder contains all distribution files.

The `tests` folder contains the Jest scripts used to verify the matchers work as designed.

```
├── src
│ ├── core
| │ └── <categories>
│ ├── matchers
| │ └── <categories>
│ ├── setup
| ├── core.js
| ├── matchers.js
| └── typedefinitions.js
├── tests
| ├── <categories>
│ ├── core.test.js
| └── matchers.test.js
```

The `core` folder contains the key functionality.

The `matchers` folder contains the matchers that use core functions.
- `src`: contains all distribution files
- `core`: contains the key functionality used throughout
- `matchers`: contains the matchers powered by the core functions
- `setup`: contains the scripts that install the matchers into the Jest runtime
- `core.js` and `matchers.js`: export a single object containing their categories as object members, each with their respective functions
- `typedefinitions.js`: documents the project's JSDoc type definitions and contains no actual code
- `tests`: the Jest scripts used to verify the matchers work as designed

The `setup` folder contains the scripts that install the matchers into the Jest runtime. `package.json` references these in entry points.

The `core`, `matchers`, `setup`, and `tests` folder each have the same subfolder structure:

```
├── boundingBoxes
├── coordinates
├── features
├── featureCollections
├── functional
├── geometries
└── geometryCollections
```

The `core.js` and `matchers.js` consolidate and export their respective elements grouped by folder structure category. When adding a new matcher, refer to the instructions in the comments at the top of these files.

`typedefinitions.js` document the project's JSDoc type definitions and contains no actual code.
`package.json` contains entry points for `core.js`, `matchers.js`, and each of the loading scripts in `setup`.

### Building

Expand All @@ -166,7 +153,9 @@ This project provides high working confidence to developers by uses Jest itself

```bash
npm run test # Runs all tests and generates coverage report

npm run test:<type> #runs the tests only in that category

npm run watch # Runs tests in watch mode
```

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,12 @@ _Future_

## Functional

- [toBeValidGeoJSON](https://m-scott-lassiter.github.io/jest-geojson/Matchers.Functional.html#.toBeValidGeoJSON)

---

_Future_

- [ ] toBeValidGeoJSON
- [ ] toHave2DBoundingBox
- [ ] toHave3DBoundingBox
- [ ] toHaveBoundingBox
Expand Down
15 changes: 14 additions & 1 deletion docs/Core.BoundingBoxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ <h3>Namespaces</h3>
>commonGeometryValidation</a
>
</li>
<li data-type="method">
<a href="Core.Utilities.html#.validGeoJSON">validGeoJSON</a>
</li>
</ul>
</li>
<li><a href="Matchers.html">Matchers</a></li>
Expand Down Expand Up @@ -196,6 +199,16 @@ <h3>Namespaces</h3>
</li>
</ul>
</li>
<li>
<a href="Matchers.Functional.html">Matchers.Functional</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Functional.html#.toBeValidGeoJSON"
>toBeValidGeoJSON</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Geometries.html">Matchers.Geometries</a>
<ul class="methods">
Expand Down Expand Up @@ -262,7 +275,7 @@ <h2>
<ul class="dummy">
<li>
<a href="typedefinitions.js.html">typedefinitions.js</a>,
<a href="typedefinitions.js.html#line79">line 79</a>
<a href="typedefinitions.js.html#line85">line 85</a>
</li>
</ul>
</dd>
Expand Down
15 changes: 14 additions & 1 deletion docs/Core.Coordinates.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ <h3>Namespaces</h3>
>commonGeometryValidation</a
>
</li>
<li data-type="method">
<a href="Core.Utilities.html#.validGeoJSON">validGeoJSON</a>
</li>
</ul>
</li>
<li><a href="Matchers.html">Matchers</a></li>
Expand Down Expand Up @@ -196,6 +199,16 @@ <h3>Namespaces</h3>
</li>
</ul>
</li>
<li>
<a href="Matchers.Functional.html">Matchers.Functional</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Functional.html#.toBeValidGeoJSON"
>toBeValidGeoJSON</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Geometries.html">Matchers.Geometries</a>
<ul class="methods">
Expand Down Expand Up @@ -262,7 +275,7 @@ <h2>
<ul class="dummy">
<li>
<a href="typedefinitions.js.html">typedefinitions.js</a>,
<a href="typedefinitions.js.html#line72">line 72</a>
<a href="typedefinitions.js.html#line78">line 78</a>
</li>
</ul>
</dd>
Expand Down
15 changes: 14 additions & 1 deletion docs/Core.FeatureCollections.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ <h3>Namespaces</h3>
>commonGeometryValidation</a
>
</li>
<li data-type="method">
<a href="Core.Utilities.html#.validGeoJSON">validGeoJSON</a>
</li>
</ul>
</li>
<li><a href="Matchers.html">Matchers</a></li>
Expand Down Expand Up @@ -196,6 +199,16 @@ <h3>Namespaces</h3>
</li>
</ul>
</li>
<li>
<a href="Matchers.Functional.html">Matchers.Functional</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Functional.html#.toBeValidGeoJSON"
>toBeValidGeoJSON</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Geometries.html">Matchers.Geometries</a>
<ul class="methods">
Expand Down Expand Up @@ -262,7 +275,7 @@ <h2>
<ul class="dummy">
<li>
<a href="typedefinitions.js.html">typedefinitions.js</a>,
<a href="typedefinitions.js.html#line86">line 86</a>
<a href="typedefinitions.js.html#line92">line 92</a>
</li>
</ul>
</dd>
Expand Down
15 changes: 14 additions & 1 deletion docs/Core.Features.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ <h3>Namespaces</h3>
>commonGeometryValidation</a
>
</li>
<li data-type="method">
<a href="Core.Utilities.html#.validGeoJSON">validGeoJSON</a>
</li>
</ul>
</li>
<li><a href="Matchers.html">Matchers</a></li>
Expand Down Expand Up @@ -196,6 +199,16 @@ <h3>Namespaces</h3>
</li>
</ul>
</li>
<li>
<a href="Matchers.Functional.html">Matchers.Functional</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Functional.html#.toBeValidGeoJSON"
>toBeValidGeoJSON</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Geometries.html">Matchers.Geometries</a>
<ul class="methods">
Expand Down Expand Up @@ -262,7 +275,7 @@ <h2>
<ul class="dummy">
<li>
<a href="typedefinitions.js.html">typedefinitions.js</a>,
<a href="typedefinitions.js.html#line93">line 93</a>
<a href="typedefinitions.js.html#line99">line 99</a>
</li>
</ul>
</dd>
Expand Down
15 changes: 14 additions & 1 deletion docs/Core.Geometries.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ <h3>Namespaces</h3>
>commonGeometryValidation</a
>
</li>
<li data-type="method">
<a href="Core.Utilities.html#.validGeoJSON">validGeoJSON</a>
</li>
</ul>
</li>
<li><a href="Matchers.html">Matchers</a></li>
Expand Down Expand Up @@ -196,6 +199,16 @@ <h3>Namespaces</h3>
</li>
</ul>
</li>
<li>
<a href="Matchers.Functional.html">Matchers.Functional</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Functional.html#.toBeValidGeoJSON"
>toBeValidGeoJSON</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Geometries.html">Matchers.Geometries</a>
<ul class="methods">
Expand Down Expand Up @@ -262,7 +275,7 @@ <h2>
<ul class="dummy">
<li>
<a href="typedefinitions.js.html">typedefinitions.js</a>,
<a href="typedefinitions.js.html#line100">line 100</a>
<a href="typedefinitions.js.html#line106">line 106</a>
</li>
</ul>
</dd>
Expand Down
Loading

0 comments on commit bf67420

Please sign in to comment.