Skip to content

Commit

Permalink
Fix new page url with options
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Oct 12, 2015
1 parent f071ef9 commit 2387ce4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions examples/hello-world/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@ var http = require('http');
var name = process.argv[2] || 'World';

http.createServer(function(req, res) {
if (req.url.indexOf('/echo') === 0) {
res.setHeader('Content-Type', 'application/json');
return res.end(JSON.stringify({
method: req.method,
url: req.url,
headers: req.headers
}));
}
res.end('Hello ' + name);
}).listen(process.env.PORT || 3000);
2 changes: 1 addition & 1 deletion lib/processes/proxy/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function trimHash(url) {
}

function normalizeOptions(options) {
options.url = trimHash(options.url);
options.url = trimHash(options.url || '/');
options.redirect = options.redirect === true || options.redirect === 'true';
return options;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/testium-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function extendUrlWithQuery(url, queryArgs) {
var parts = urlLib.parse(url);
var query = _.extend(qs.parse(parts.query), queryArgs);
parts.search = '?' + qs.stringify(query);
urlLib.format(_.pick(
return urlLib.format(_.pick(
parts,
'protocol',
'slashes',
Expand Down
7 changes: 6 additions & 1 deletion test/testium-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ tap.test('Init against hello-world', function(t) {
})
.then(function(result) {
t.equal(result, 'Hello Quinn', 'New page url redirects to target');
return fetchResponse(testium.getNewPageUrl('/echo', { 'x': 'y' }));
return fetchResponse(
testium.getNewPageUrl('/echo', { query: { 'x': 'y' } }), { json: true });
})
.then(function(response) {
var echo = response.body;
t.equal(echo.method, 'GET');
t.equal(echo.url, '/echo?x=y');

t.ok(response.headers['set-cookie'], 'Sets a cookie');
t.ok(('' + response.headers['set-cookie']).indexOf('_testium_=') !== -1,
'Sets a _testium_ cookie');
Expand Down

0 comments on commit 2387ce4

Please sign in to comment.