Created
May 7, 2014 13:04
-
-
Save marcusoftnet/dd41804d0b6bb2dff256 to your computer and use it in GitHub Desktop.
KoaMongoBlog test update existing post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('./app.js'); | |
var co = require('co'); | |
var should = require('should'); | |
var request = require('supertest').agent(app.listen()); | |
var posts = require('./blogRoutes.js').posts; | |
describe('Blog with mongo:', function(){ | |
var removeAll = function(done){ | |
co(function *(){ | |
yield posts.remove({}); | |
})(done); | |
}; | |
beforeEach(function (done) { | |
removeAll(done); | |
}); | |
afterEach(function (done) { | |
removeAll(done); | |
}); | |
var test_post = { title: 'A nice title', body : 'Short body. Yeah!'}; | |
it('updates an existing post', function(done){ | |
co(function *(){ | |
var post = yield posts.insert(test_post); | |
var postUrl = '/post/' + post._id; | |
request | |
.post(postUrl) | |
.send({title: 'Updated title', body: 'Updated body'}) | |
.expect(302) | |
.expect('location', postUrl); | |
})(done); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment