Skip to content

Commit

Permalink
Added browser.external.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 13, 2010
1 parent b17bf9d commit 8a924e6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
43 changes: 43 additions & 0 deletions test/browser.external.test.js
@@ -0,0 +1,43 @@

/**
* Module dependencies.
*/

var tobi = require('tobi')
, express = require('express')
, Browser = tobi.Browser
, should = require('should');

// Test app

var app = express.createServer();

app.use(express.bodyDecoder());

app.get('/script', function(req, res, next){
res.send('<script>document.getElementById("para").innerHTML = "<em>new</em>";</script><p id="para">old</p>');
});

module.exports = {
'test external option disabled': function(done){
var browser = tobi.createBrowser(app);
browser.get('/script', function(res, $){
res.should.have.status(200);
$('p').should.have.text('old');
done();
});
},

'test external option enabled': function(done){
var browser = tobi.createBrowser(app, { external: true });
browser.get('/script', function(res, $){
res.should.have.status(200);
$('p').should.have.text('new');
done();
});
},

after: function(){
app.close();
}
};
22 changes: 0 additions & 22 deletions test/browser.navigation.test.js
Expand Up @@ -75,10 +75,6 @@ app.get('/search/results', function(req, res){
res.send(req.query);
});

app.get('/script', function(req, res, next){
res.send('<script>document.getElementById("para").innerHTML = "<em>new</em>";</script><p id="para">old</p>');
});

app.get('/form', function(req, res){
res.send('<form id="user" method="post">'
+ '<input id="user-name" type="text" name="user[name]" />'
Expand All @@ -104,24 +100,6 @@ app.post('/form', function(req, res){
});

module.exports = {
'test external option disabled': function(done){
var browser = tobi.createBrowser(app);
browser.get('/script', function(res, $){
res.should.have.status(200);
$('p').should.have.text('old');
done();
});
},

'test external option enabled': function(done){
var browser = tobi.createBrowser(app, { external: true });
browser.get('/script', function(res, $){
res.should.have.status(200);
$('p').should.have.text('new');
done();
});
},

'test .request() invalid response': function(done){
var browser = tobi.createBrowser(app);
browser.on('error', function(err){
Expand Down

0 comments on commit 8a924e6

Please sign in to comment.