Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
vrozaev committed Sep 25, 2017
1 parent b6bb57b commit 734e1a6
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions lib/reporters/Html.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
define([
'require',
'../util',
], function (require, util) {

'../util'
], function (
require,

util
) {
var location = window.location;

function getFullName(test) {
var name = test.name;
while (test.parent && test.parent.name) {
test = test.parent;
name = test.name + ' - ' + name;
}
return name;
}

function createLinkNode(test) {
var text = test.name;
var a = document.createElement('a');
var search = location.search;

if (search) {
search = search.slice(1).split("&").filter(function (el) {
return !el.startsWith("grep");
}).join("&");
}

search = "?" + search + "&grep=/" + getFullName(test) + "/";
a.href = location.origin + location.pathname + search;
a.appendChild(document.createTextNode(text));
return a;
}

function pad(value, size) {
var padded = String(value);

Expand Down Expand Up @@ -338,7 +371,7 @@ define([
suiteCount++;

cellNode.className = 'title';
cellNode.appendChild(document.createTextNode(suite.name));
cellNode.appendChild(createLinkNode(suite));
rowNode.className = 'suite';
rowNode.appendChild(cellNode);
reportNode.appendChild(rowNode);
Expand Down Expand Up @@ -393,7 +426,7 @@ define([
var numSkippedTests = suite.numSkippedTests;
var numPassedTests = numTests - numFailedTests - numSkippedTests;

// Mark a suite as failed if any of its child tests failed, and
// Mark a suite as failed if any of its child tests failed, and
addClass(rowNode, numFailedTests > 0 ? 'failed' : 'passed');

// Only suites with failed tests will be initially expanded
Expand Down Expand Up @@ -471,7 +504,7 @@ define([
cellNode.className += ' indent' + indentLevel;
}

cellNode.appendChild(document.createTextNode(test.name));
cellNode.appendChild(createLinkNode(test));
rowNode.appendChild(cellNode);

cellNode = document.createElement('td');
Expand Down

0 comments on commit 734e1a6

Please sign in to comment.