Skip to content

Commit

Permalink
Merge pull request #1358 from boneskull/queryparams
Browse files Browse the repository at this point in the history
HTML reporter: preserve query params when navigating to suites/tests
  • Loading branch information
Christopher Hiller committed Oct 17, 2014
2 parents 6944b03 + 91828f9 commit 9b747db
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,23 @@ function HTML(runner) {
});
}

/**
* Makes a URL, preserving querystring ("search") parameters.
* @param {string} s
* @returns {string} your new URL
*/
var makeUrl = function makeUrl(s) {
var search = window.location.search;
return (search ? search + '&' : '?' ) + 'grep=' + encodeURIComponent(s);
};

/**
* Provide suite URL
*
* @param {Object} [suite]
*/

HTML.prototype.suiteURL = function(suite){
return '?grep=' + encodeURIComponent(suite.fullTitle());
return makeUrl(suite.fullTitle());
};

/**
Expand All @@ -193,7 +202,7 @@ HTML.prototype.suiteURL = function(suite){
*/

HTML.prototype.testURL = function(test){
return '?grep=' + encodeURIComponent(test.fullTitle());
return makeUrl(test.fullTitle());
};

/**
Expand Down

0 comments on commit 9b747db

Please sign in to comment.