Skip to content

Commit

Permalink
Merge branch 'master' into searchFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellarita authored Jan 18, 2017
2 parents 38be386 + cf23b1e commit 98b1810
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
32 changes: 32 additions & 0 deletions server/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,35 @@ describe('/api/users', () => {
)
})
})


describe('/api/products', () => {
it('GET /', () =>
request(app)
.get(`/api/products/1`)
.expect(200)
)

it('POST creates a user', () =>
request(app)
.post('/api/users')
.send({
email: '[email protected]',
password: '12345'
})
.expect(201)
)

it('POST redirects to the user it just made', () =>
request(app)
.post('/api/users')
.send({
email: '[email protected]',
password: '23456',
})
.redirects(1)
.then(res => expect(res.body).to.contain({
email: '[email protected]'
}))
)
})
2 changes: 1 addition & 1 deletion server/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ customProductsRoutes.get('/:productId', function(request,response,next){
}
})
.then((product)=>{
response.json(product)
response.status(200).json(product)
})
.catch(next);
})
Expand Down
12 changes: 4 additions & 8 deletions server/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ customUserRoutes.post('/', function (request, response, next) {
email: request.body.email,
password: request.body.password
}

User.create(newUserToCreate)
.then((result) => {
response.sendStatus(201);
}).catch(function(err){
console.log(err)
next();
});
User.create(newUserToCreate)
.then((user) => {
response.sendStatus(201);
}).catch(next);
});

customUserRoutes.delete('/:userId', function (request, response, next) {
Expand Down

0 comments on commit 98b1810

Please sign in to comment.