Skip to content

Commit 3bafdea

Browse files
committed
add third
1 parent e100d21 commit 3bafdea

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

server/api/locations/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ router.param('id', (req, res, next, id) => {
2121

2222
// // get location by url
2323
router.post('/', (req, res, next) => {
24-
Location.findOne({ where: { url: req.body.location } })
25-
.then(location => res.send(location))
24+
Location.findOne({ where: { url: req.body.locations } })
25+
.then(location => {
26+
//console.log("location", location)
27+
res.send(location)
28+
})
2629
.catch(next)
2730
})
2831

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { expect } = require('chai')
2+
const supertest = require('supertest')
3+
const db = require('../../db')
4+
const app = require('../../')
5+
const Location = db.model('location')
6+
7+
describe('Location routes', () => {
8+
let agent;
9+
beforeEach(() => {
10+
agent = supertest(app);
11+
return db.sync({ force: true })
12+
})
13+
14+
describe('/api/locations', () => {
15+
const url = 'https://www.youtube.com/watch?v=BMUiFMZr7vk'
16+
17+
beforeEach(() => {
18+
return Location.create({ url })
19+
})
20+
21+
22+
it('POST /api/locations', () => {
23+
return agent
24+
.post('/api/locations')
25+
.send({
26+
locations: 'https://www.youtube.com/watch?v=BMUiFMZr7vk'
27+
})
28+
.expect(200)
29+
.then(res => {
30+
const createLocations = res.body;
31+
//console.log("CREATE", createLocations)
32+
return Location.findById(createLocations.id)
33+
})
34+
.then(foundLocation => {
35+
console.log("FOUND", foundLocation)
36+
expect(foundLocation.url).to.be.equal('https://www.youtube.com/watch?v=BMUiFMZr7vk');
37+
})
38+
})
39+
})
40+
})

0 commit comments

Comments
 (0)