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

lab14-Jeremiah 11 Test Passing #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jtwalters25
Copy link

No description provided.

@jtwalters25 jtwalters25 changed the title Some test Passing lab14-Jeremiah 11 Test Passing Mar 3, 2017
const lotSchema = Schema({
name: { type: String, required: true },
timestamp: { type: Date, required: true },
cars: [{ type: Schema.Types.ObjectId, ref: 'car' }]
Copy link

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)));
Copy link

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')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic!

request.post(`${url}/api/lot`)
.send('stting')
.set('Content-Type', 'application/json')
.end((err, res)=> {
Copy link

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.

Copy link
Author

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!

it('should return a 404 error', done => {
request.post(`${url}/api/lot/2345`)
.end((err, res) => {
expect(res.status).to.equal(404);
Copy link

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.

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) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indention.


it('should return a car', done => {
request.get( `${url}/api/car/${this.tempCar._id}`)
.end((err, res) => {
Copy link

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', function(){
it('should return a 404', done => {
request.get(`${url}/api/car/6574`)
.end((err, res) =>{
Copy link

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) => {
Copy link

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')
Copy link

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) => {
Copy link

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

---->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants