Browse Source

housekeeping renaming controllers to match CRUD and updated tests to reflect failing "/" route

main
suroh 5 months ago
parent
commit
eaacb89abc
  1. 2
      README.md
  2. 15
      backend/controllers/points.js
  3. 4
      backend/routes/api.js
  4. 5
      backend/tests/routes.js

2
README.md

@ -24,7 +24,7 @@ Then you should be able to run the dev server :
$ npm run dev
```
You should now be able to access ethermaps on [`http://localhost:3000`](http://localhost:3000/) (or whichever port you configured in your `.env` file).
You should now be able to access ethermaps on [http://localhost:3000](http://localhost:3000/) (or whichever port you configured in your `.env` file).
## Desires

15
backend/controllers/points.js

@ -1,11 +1,9 @@
import MapModel from '../db/models/map.js'
const setPoint = async (req, res, next) => {
const createPoint = async (req, res, next) => {
try {
const { mapId, point } = req.body
console.log(req.body)
const map = await MapModel.query().findById(mapId)
const p = await map.$relatedQuery('map_points').insert(point)
@ -15,4 +13,13 @@ const setPoint = async (req, res, next) => {
}
}
export { setPoint }
const updatePoint = async (req, res, next) => {
}
const deletePoint = async (req, res, next) => {
}
export { createPoint, updatePoint, deletePoint }

4
backend/routes/api.js

@ -9,7 +9,7 @@ router.get('/maps', getAllMaps)
router.get('/map/:mapName', getMapByName)
// POINTS
import { setPoint } from '../controllers/points.js'
router.post('/point/add', setPoint)
import { createPoint } from '../controllers/points.js'
router.post('/point/add', createPoint)
export default router

5
backend/tests/routes.js

@ -6,15 +6,14 @@ import request from 'supertest'
import App from '../express.js'
import db from '../db/DB.js'
test.before(async t => {
test.before(async () => {
await db.migrate.latest()
})
test.serial('get "/" route should return body of "ethermap"', async t => {
test.failing('get "/" route should return status code of 200', async t => {
const res = await request(App).get('/')
t.is(res.status, 200)
t.is(res.text, 'ethermap')
})
test.serial('get "/api/maps" route should return an object containing an array called "maps"', async t => {

Loading…
Cancel
Save