Last active
August 29, 2015 13:57
-
-
Save seansullivan/9924729 to your computer and use it in GitHub Desktop.
Setting the locals for an Express render() as the response body for testing purposes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// Route defined as: | |
app.get('/test/login', function (req, res) { | |
res.render('login/login', {something: 'here'}); | |
}); | |
*/ | |
var localsAsResponseEngine = function (pathName, locals, cb) { | |
delete locals._locals; | |
delete locals.settings; | |
cb(null, locals); | |
}; | |
describe("Auth Server Endpoints", function() { | |
var app = require('../app'); | |
describe('Base Views', function() { | |
it('Should respond with login form', function (done) { | |
app.engine('html', localsAsResponseEngine); | |
request(app) | |
.get('/test/login') | |
.expect(200) | |
.end(function (req, res) { | |
var context = res.body; | |
expect(context).to.have.property('something'); | |
expect(context.something).to.equal('here'); | |
done(); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment