LearnBoost / tobi

Tobi: Expressive server-side functional testing with jQuery
408 stars 33 forks source link

fix lib/cookie/index.js: when no path specified and req is undefined the... #94

Closed vklap closed 1 year ago

vklap commented 10 years ago

Hi,

After adding support for cookies and session in express version 4 - my functional tests stopped working.

Bellow are the functional tests + comments with some explanations.

Anyway, thanks for this amazing library.

BR, Victor N.B.:

var www = require('../../bin/www'); var tobi = require('tobi'); var app = require('../../app'); var browser = tobi.createBrowser(3000, '127.0.0.1');

describe('index', function() { it ('should get index', function(done) { // This is the line of code that didn't work - got the following error: // "TypeError: Cannot read property 'url' of undefined" browser.get('/', function(res, $) { res.should.have.status(200);

  $('nav.main a:nth-child(1)').should.have.attr('href', '/');
  $('nav.main a:nth-child(2)').should.have.attr('href', '/how-it-works');
  $('nav.main a:nth-child(3)').should.have.attr('href', '/why');
  $('nav.main a:nth-child(4)').should.have.attr('href', '/learn-more');
  $('nav.main a:nth-child(5)').should.have.attr('href', '/faq');
  $('nav.main a:nth-child(6)').should.have.attr('href', '/register');
  $('nav.main a:nth-child(7)').should.have.attr('href', '/login');

  $('nav.bottom a:nth-child(1)').should.have.attr('href', '/');
  $('nav.bottom a:nth-child(2)').should.have.attr('href', '/faq');
  $('nav.bottom a:nth-child(3)').should.have.attr('href', '/register');
  $('nav.bottom a:nth-child(4)').should.have.attr('href', '/buy');
  $('nav.bottom a:nth-child(5)').should.have.attr('href', '/about-us');
  $('nav.bottom a:nth-child(6)').should.have.attr('href', '/contact-us');

  $('body').should.have.one('h1', 'Express');
  done();
});

});

// I've added this test in order to make sure my fix will work with other url's it ('should get register page', function(done) { browser.get('/register', function(res, $) { res.should.have.status(200); done(); }); });

});