Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toBeValidGeoJSON #26

Closed
M-Scott-Lassiter opened this issue May 24, 2022 · 2 comments
Closed

toBeValidGeoJSON #26

M-Scott-Lassiter opened this issue May 24, 2022 · 2 comments

Comments

@M-Scott-Lassiter
Copy link
Owner

M-Scott-Lassiter commented May 24, 2022

Description

This is the most generic matcher, and expected to be one of the most commonly used ones.

This matcher takes as an argument of any GeoJSON object and checks if it meets validity requirements for any of the nine types:

It does not accept individual components of these objects.

See the above links for examples.

Example Matcher Usage

point = {
    "type": "Point",
    "coordinates": [100.0, 0.0]
}
lineString = {
    "type": "LineString",
    "coordinates": [
        [
            [180.0, 40.0],
            [180.0, 50.0],
            [170.0, 50.0],
            [170.0, 40.0],
            [180.0, 40.0]
        ]
    ]
}
polygon = {
    "type": "Polygon",
    "coordinates": [
        [
            [100.0, 0.0],
            [101.0, 0.0],
            [101.0, 1.0],
            [100.0, 1.0],
            [100.0, 0.0]
        ]
    ]
}
feature = {
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [102.0, 0.5]
    }
}
geometryCollection = {
    "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]
    }]
}

expect(point).toBeValidGeoJSON()
expect(lineString).toBeValidGeoJSON()
expect(polygon).toBeValidGeoJSON()
expect(feature).toBeValidGeoJSON()
expect(feature.geometry).toBeValidGeoJSON()
expect(geometryCollection).toBeValidGeoJSON()
expect(geometryCollection.geometries[1]).toBeValidGeoJSON()

expect(polygon.coordinates).not.toBeValidGeoJSON()
expect(geometryCollection.geometries).toBeValidGeoJSON()
expect([322, -34.549, 0]).not.toBeValidGeoJSON()
expect({coordinates: [22, -34.549, 22]}).not.toBeValidGeoJSON()

Repeat Passing/Failing Tests Contained in Other Files

This matcher works with any geometry, Feature, or FeatureCollection. Therefore, the passing and failing tests for each of the nine can also include tests for toBeValidGeoJSON.

Unique Tests

Input Not an Object

-undefined
-null
-Booleans: true, false
-Numbers: 200, -200, Infinity, -Infinity, NaN
-Arrays: [25, 35, 45000], [[0, 0], [1, 1]], [ ]
-Strings: '', 'Random Geometry', '[0, 0]', '[[0, 0], [0, 0]]'

  • Stringified JSON:
    JSON.stringify({
        type: "LineString",
        coordinates: [[25, 90], [2, 2]]
    })

Non-Object GeoJSON Components

  • Rejects Coordinates
  • Rejects Bounding Boxes
  • Rejects array of geometries

Other

  • Snapshots
@M-Scott-Lassiter M-Scott-Lassiter added the new matcher proposal Proposal for a new GeoJSON matcher label May 24, 2022
@M-Scott-Lassiter M-Scott-Lassiter self-assigned this May 24, 2022
@M-Scott-Lassiter M-Scott-Lassiter added this to To do in Functional via automation May 24, 2022
@M-Scott-Lassiter M-Scott-Lassiter changed the title [New Matcher]: toBeValidGeoJSON toBeValidGeoJSON May 24, 2022
@M-Scott-Lassiter M-Scott-Lassiter removed this from the Initial Release v1.0.0 milestone Jun 2, 2022
@M-Scott-Lassiter
Copy link
Owner Author

Removed from v1.0.0 milestone because all functionality contained within is already in other component functions. This will come as one of the next release matchers.

Functional automation moved this from To do to Done Jun 4, 2022
github-actions bot pushed a commit that referenced this issue Jun 4, 2022
## [1.1.0](v1.0.0...v1.1.0) (2022-06-04)

### 🎁 Feature Changes

* **toBeValidGeoJSON:** add new matcher ([bf67420](bf67420)), closes [#26](#26)
@M-Scott-Lassiter
Copy link
Owner Author

🎉 This issue has been resolved in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@M-Scott-Lassiter M-Scott-Lassiter added released matchers/functional and removed new matcher proposal Proposal for a new GeoJSON matcher labels Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Functional
  
Done
Development

No branches or pull requests

1 participant