Skip to content

Commit

Permalink
Added another JSON GET example
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 18, 2011
1 parent c65768d commit 8fa97e5
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/browser.navigation.test.js
Expand Up @@ -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' });
});
Expand Down Expand Up @@ -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';
Expand All @@ -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();
}
Expand Down

0 comments on commit 8fa97e5

Please sign in to comment.