Skip to content
Browse files

Added another JSON GET example

  • Loading branch information...
1 parent c65768d commit 8fa97e56c9dbfb2b9f83e98caabf39c2d9be1a36 @tj tj committed Oct 18, 2011
Showing with 28 additions and 2 deletions.
  1. +28 −2 test/browser.navigation.test.js
View
30 test/browser.navigation.test.js
@@ -50,6 +50,18 @@ app.get('/json', function(req, res){
res.send({ user: 'tj' });
});
+app.get('/users.json', function(req, res){
+ res.send([
+ { name: 'tobi' }
+ , { name: 'loki' }
+ , { name: 'jane' }
+ ]);
+});
+
+app.get('/users', function(req, res){
+ res.send('<html><body><a href="/users.json">Users JSON</a></body></html>');
+});
+
app.get('/invalid-json', function(req, res){
res.send('{"broken":', { 'Content-Type': 'application/json' });
});
@@ -924,8 +936,8 @@ module.exports = {
},
'test setting user-agent': function(done){
- var browser = tobi.createBrowser(80,'whatsmyuseragent.com');
- browser.get('http://whatsmyuseragent.com', function(res,$){
+ var browser = tobi.createBrowser(80, 'whatsmyuseragent.com');
+ browser.get('http://whatsmyuseragent.com', function(res, $){
res.should.have.status(200);
$('h4:first').should.have.text('');
browser.userAgent = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30';
@@ -937,6 +949,20 @@ module.exports = {
});
},
+ 'test JSON link': function(done){
+ var browser = tobi.createBrowser(app);
+ browser.get('/users', function(res, $){
+ $('a').click(function(res, obj){
+ obj.should.eql([
+ { name: 'tobi' }
+ , { name: 'loki' }
+ , { name: 'jane' }
+ ]);
+ done();
+ });
+ });
+ },
+
after: function(){
app.close();
}

0 comments on commit 8fa97e5

Please sign in to comment.
Something went wrong with that request. Please try again.