Skip to content

Instantly share code, notes, and snippets.

@hugeuser
Created February 28, 2014 14:55
Show Gist options
  • Save hugeuser/9272508 to your computer and use it in GitHub Desktop.
Save hugeuser/9272508 to your computer and use it in GitHub Desktop.
TDD format
var async = require('async'),
request = require('supertest'),
should = require('should'),
app = require('../server'),
connection = require('../database');
suite('Landing page functionality', function(){
setup(function (done) {
this.timeout(5000);
async.series([
function (cb) {
connection.query('INSERT INTO mocha_test_table '+
'VALUE("TEST","TEST","","");',function(err){
done();
});
},
function (cb) {
connection.query('SELECT * FROM mocha_test_table WHERE user_name="TEST"'+
' AND email="TEST";',function(err,results){
results.length.should.not.equal(0);
done();
});
}
], done);
});
test('Text of landing page', function(done){
request(app)
.get('/')
.expect(200)
.end(function (err, res) {
res.text.should.include('Home');
done();
});
});
});
// Find the rest of the test code in the source link below
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment