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

Revitalize tests #232

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ parameter to programmatically refresh the column cache, such as in situations in
which the underlying data has been changed (editing, adding, etc).

## Running
NOTICE: To start the API, run "yarn run start". To run the unit tests, run `tsc`, which will create a test directory called "v2test", this can be changed in tsconfig.json. Then run `yarn run test` to run the tests. All information below this notice in the "Running" section is potentially deprecated and needs to be reviewed.

===============================================================================

To start the API simply run `node server.js` which will start a process on
port 5050. Note that the default port was changed from 5000 to 5050 to avoid a
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "macrostrat-api",
"version": "3.0.0-dev",
"description": "The API for SCIENCE",
"main": "server.js",
"main": "server.ts",
"repository": {
"type": "git",
"url": "https://github.com/UW-Macrostrat/macrostrat-api.git"
Expand All @@ -11,7 +11,7 @@
"start": "nodemon --watch v2 --exec ts-node --transpileOnly server.ts",
"docker": "docker build -t macrostrat-api . && docker run --rm -it -p 5000:5000 macrostrat-api",
"serve": "ts-node --transpileOnly server.ts",
"test": "mocha ./v2",
"test": "mocha --require ts-node/register/transpile-only './v2test/test/test.js'",
"defs": "ts-node --transpileOnly ./v2/utilities/validateDefs.ts",
"build-defs": "ts-node --transpileOnly ./v2/utilities/getOutputFields.ts",
"build-changes": "grip ./v2/CHANGELOG.md --export ./v2/changes.html"
Expand Down Expand Up @@ -63,14 +63,15 @@
"turf-buffer": "^1.0.4",
"turf-point": "^0.1.6",
"turf-voronoi": "git+https://github.com/Turfjs/turf-voronoi.git",
"typescript": "^5.3.3",
"typescript": "^5.4.4",
"underscore": "^1.8.3",
"universal-analytics": "^0.4.6",
"wellknown": "^0.3.0",
"yesql": "^7.0.0"
},
"devDependencies": {
"mocha": "^1.21.4",
"@types/mocha": "^10.0.6",
"mocha": "^10.4.0",
"node-uuid": "^1.4.3",
"nodemon": "^3.0.3",
"prettier": "^3.2.3",
Expand Down
5 changes: 3 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var express = require("express"),
bodyParser = require("body-parser"),
//v1 = require("./v1"),
v2 = require("./v2"),
defs = require("./v2/defs"),
v2 = require("./v2test"),
defs = require("./v2test/defs"),
app = express();

var ua = require("universal-analytics");
Expand Down Expand Up @@ -67,3 +67,4 @@ if (!module.parent) {
}

module.exports = app;
//export { app };
13 changes: 9 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"compilerOptions": {
"moduleResolution": "NodeNext",
"module": "NodeNext",
},
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "./v2test",
"strict": true
},
"include": ["./v2/**/*.ts"],
"exclude": ["node_modules"]
}

1 change: 1 addition & 0 deletions v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ api.use(function (err, req, res, next) {
});

module.exports = api;
//export {api};
5 changes: 3 additions & 2 deletions v2/test/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
port: 5555,
module.exports = {
port: 5550,
get host() {
return "http://localhost:" + this.port;
},
};
//export {toExport};
5 changes: 3 additions & 2 deletions v2/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var should = require("should");
var settings = require("./settings");
var app = require("../../server");

//import { toExport as settings } from "./settings";
var app = require("../../server.ts");
//import { app } from "../../server";
app.port = settings.port;

app.start();
Expand Down
6 changes: 3 additions & 3 deletions v2/test/v2Tests/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function () {

it("should return metadata", function (done) {
request(settings.host)
.get("/api/v2/columns")
.get("/v2/columns")
.expect(validators.aSuccessfulRequest)
.expect(validators.json)
.expect(validators.metadata)
Expand All @@ -17,7 +17,7 @@ module.exports = function () {

it("should return a sample", function (done) {
request(settings.host)
.get("/api/v2/columns?sample")
.get("/v2/columns?sample")
.expect(validators.aSuccessfulRequest)
.expect(validators.json)
.expect(validators.aSample)
Expand All @@ -29,7 +29,7 @@ module.exports = function () {

it("should accept an interval name", function (done) {
request(settings.host)
.get("/api/v2/columns?interval_name=Permian")
.get("/v2/columns?interval_name=Permian")
.expect(validators.aSuccessfulRequest)
.expect(validators.json)
.expect(validators.atLeastOneResult)
Expand Down
Loading
Loading