forked from koajs/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request koajs#88 from bananaappletw/master
Update co-views to fix swig cache problem and add test for blog
- Loading branch information
Showing
3 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var app = require('./app'); | ||
var request = require('supertest').agent(app.listen()); | ||
|
||
describe('Blog', function(){ | ||
describe('GET /',function(){ | ||
it('should see title "Posts"', function(done){ | ||
request | ||
.get('/') | ||
.expect(200, function(err, res){ | ||
if (err) return done(err); | ||
|
||
res.should.be.html; | ||
res.text.should.include('<title>Posts</title>'); | ||
done(); | ||
}); | ||
}); | ||
it('should see 0 post', function(done){ | ||
request | ||
.get('/') | ||
.expect(200, function(err, res){ | ||
if (err) return done(err); | ||
|
||
res.should.be.html; | ||
res.text.should.include('<p>You have <strong>0</strong> posts!</p>'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('POST /post/new',function(){ | ||
it('should create post and redirect to /', function(done){ | ||
request | ||
.post('/post') | ||
.send({title: 'Title', body: 'Contents'}) | ||
.end(function(err, res){ | ||
if (err) return done(err); | ||
|
||
res.header.location.should.be.equal('/') | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('GET /post/0',function(){ | ||
it('should see post', function(done){ | ||
request | ||
.get('/post/0') | ||
.expect(200, function(err, res){ | ||
if (err) return done(err); | ||
|
||
res.should.be.html; | ||
res.text.should.include('<h1>Title</h1>') | ||
res.text.should.include('<p>Contents</p>') | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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