Skip to content

Commit

Permalink
added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterprovoost committed Jul 17, 2023
1 parent 15deaf9 commit badccf0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
testMatch: [
"<rootDir>/src/**/*.test.js",
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"scripts": {
"start": "PORT=3006 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test": "react-scripts test --watchAll --transformIgnorePatterns 'node_modules/(?!wktmap)/'",
"eject": "react-scripts eject"
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion src/wkt.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ async function transformInput(input) {

}

export { parseWkt, transformInput, ValueError };
export { parseWkt, transformInput, ValueError, fetchProj };
25 changes: 25 additions & 0 deletions src/wkt.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { parseWkt, fetchProj } from "./wkt";

describe("parseWkt", () => {
it("parses wkt", () => {
const wkt = "POINT (30 10)";
const json = parseWkt(wkt);
expect(json).toEqual({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [30, 10]
},
"properties": null
});
});
});

describe("fetchProj", () => {
it("fetches proj", () => {
(async () =>{
const proj = await fetchProj(4326);
expect(proj).toEqual("+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
})();
});
});

0 comments on commit badccf0

Please sign in to comment.