Created
July 21, 2012 16:27
-
-
Save richzw/3156327 to your computer and use it in GitHub Desktop.
redirect test for api easy
This file contains 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
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