Skip to content

Instantly share code, notes, and snippets.

@richzw
Created July 21, 2012 16:27
Show Gist options
  • Save richzw/3156327 to your computer and use it in GitHub Desktop.
Save richzw/3156327 to your computer and use it in GitHub Desktop.
redirect test for api easy
var APIeasy = require('api-easy'),
assert = require('assert');
var suite = APIeasy.describe('/api');
var urlRedir;
suite.discuss('Test Redirection API')
.use('localhost', 3000)
.setHeader('Content-Type', 'application/json')
.followRedirect(false)
.path('/login')
.post({user: {email:'tmp@gmail.com', password:'tmp'}})
.expect(302)
.expect('redirect content', function (err, res, body) {
urlRedir = res.headers.location;
})
.next()
.get(urlRedir) //the urlRedir is null, the real url is /login and this is from path()
.expect(200)
.expect('get redir url content', function(err, res, body){
console.log(body);
})
.export(module);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment