-
Notifications
You must be signed in to change notification settings - Fork 14
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
lab14-Jeremiah 11 Test Passing #8
base: master
Are you sure you want to change the base?
lab14-Jeremiah 11 Test Passing #8
Conversation
const lotSchema = Schema({ | ||
name: { type: String, required: true }, | ||
timestamp: { type: Date, required: true }, | ||
cars: [{ type: Schema.Types.ObjectId, ref: 'car' }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be confusing. Good job referencing the 'car' correctly here.
|
||
Lot.findByIdAndAddCar(req.params.lotID, req.body) | ||
.then( car => res.json(car)) | ||
.catch( err => next(createError(404, err.message))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job creating the error to send back.
|
||
lotRouter.get('/api/lot/:id', function(req, res, next) { | ||
Lot.findById(req.params.id) | ||
.populate('cars') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic!
test/car-route-test.js
Outdated
request.post(`${url}/api/lot`) | ||
.send('stting') | ||
.set('Content-Type', 'application/json') | ||
.end((err, res)=> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have some funny indention going on here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to get in the habit of actually using my auto-indent atom package!
test/car-route-test.js
Outdated
it('should return a 404 error', done => { | ||
request.post(`${url}/api/lot/2345`) | ||
.end((err, res) => { | ||
expect(res.status).to.equal(404); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you are handling the possible err here.
test/car-route-test.js
Outdated
describe('with an invalid id or none provided', function() { | ||
it('should return a 404 error', done => { | ||
request.post(`${url}/api/lot/2345`) | ||
.end((err, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention.
test/car-route-test.js
Outdated
|
||
it('should return a car', done => { | ||
request.get( `${url}/api/car/${this.tempCar._id}`) | ||
.end((err, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention.
test/car-route-test.js
Outdated
describe('with an invalid id', function(){ | ||
it('should return a 404', done => { | ||
request.get(`${url}/api/car/6574`) | ||
.end((err, res) =>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention.
describe('with an invalid id or none provided', function() { | ||
it('should return a 404 error', done => { | ||
request.post(`${url}/api/lot/2345`) | ||
.end((err, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention.
describe('with an invalid body or none provided', function() { | ||
it('should return a 400 error', done => { | ||
request.post(`${url}/api/lot`) | ||
.send('tdd makes me angry') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're killing me here. Indention.
|
||
it('should return a lot', done => { | ||
request.get( `${url}/api/lot/${this.tempLot._id}`) | ||
.end((err, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--->
var updated = { name: 'updated name' }; | ||
|
||
request.put(`${url}/api/lot/${this.tempLot._id}`) | ||
.send(updated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
---->
No description provided.