Skip to content

Commit

Permalink
Added linking of tests in and filtering of tests through query params
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed Jan 20, 2013
1 parent 53b2567 commit 13202f6
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
10 changes: 10 additions & 0 deletions it.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ body {
overflow-y: scroll;
}

#it a {
text-decoration: none;
color: inherit;
}

#it a:hover {
text-decoration: underline;
color: inherit;
}

#it {
color: gray;
font-size: 10px;
Expand Down
23 changes: 20 additions & 3 deletions it.js
Original file line number Diff line number Diff line change
Expand Up @@ -6036,6 +6036,7 @@ EventEmitter.extend({
ret = this._static.clone(this, this.description, {
sub: this.sub,
"filtered": this.sub ? false : true,
parent: this.parent,
__ba: this.__ba.slice(0),
__aa: this.__ba.slice(0),
"__shoulds": _(this.__shoulds).map(function (action) {
Expand Down Expand Up @@ -6478,7 +6479,7 @@ Reporter.extend({
constructor: function (el) {
this._super(arguments);
this.el = document.getElementById(el);
this.header = this.el.appendChild(createDom("div", {className: "header"}, createDom("h1", {}, "It")));
this.header = this.el.appendChild(createDom("div", {className: "header"}, createDom("h1", {}, createDom("a", {href: "?"}, "It"))));
this.summary = this.header.appendChild(createDom("div", {className: "summary"}));
this.progress = this.el.appendChild(createDom("ul", {className: "progress"}));
this.actions = this.el.appendChild(createDom("div", {className: "actions"}));
Expand All @@ -6499,7 +6500,9 @@ Reporter.extend({
if (action.description) {
this.actions.appendChild(createDom("div",
{className: "header", style: "padding-left:" + getSpacing(action), "data-it-actionName": action.get("fullName")},
action.description
createDom("a", {
href: "?filter=" + encodeURIComponent(action.get("fullName"))
}, action.description)
));
}
},
Expand All @@ -6508,7 +6511,9 @@ Reporter.extend({
var summary = action.get("summary");
this.actions.appendChild(createDom("div",
{className: "pending", style: "padding-left:" + getSpacing(action), "data-it-actionName": action.get("fullName")},
format(" %s, (%dms)", action.description, summary.duration)
createDom("a", {
href: "?filter=" + encodeURIComponent(action.get("fullName"))
}, format(" %s, (%dms)", action.description, summary.duration))
));
updateActionStatus(action, summary.status);
return this;
Expand Down Expand Up @@ -8863,12 +8868,24 @@ require.define("/lib/browser/it.js",function(require,module,exports,__dirname,__
* @return {comb.Promise} a promise that is resolved once all tests are done running.
*/
run: function run(filter) {
var filter;
if (typeof window !== "undefined") {
try {
it.reporter("html", "it");
} catch (e) {
it.reporter("tap");
}
var paramStr = window.location.search.substring(1);
var params = {};
if (paramStr.length > 0) {
_(paramStr.split('&')).forEach(function (part) {
var p = part.split('=');
params[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
});
}
if (params.hasOwnProperty("filter")) {
filter = params.filter;
}
} else {
it.reporter("tap");
}
Expand Down
2 changes: 1 addition & 1 deletion it.min.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions lib/browser/formatters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Reporter.extend({
constructor: function (el) {
this._super(arguments);
this.el = document.getElementById(el);
this.header = this.el.appendChild(createDom("div", {className: "header"}, createDom("h1", {}, "It")));
this.header = this.el.appendChild(createDom("div", {className: "header"}, createDom("h1", {}, createDom("a", {href: "?"}, "It"))));
this.summary = this.header.appendChild(createDom("div", {className: "summary"}));
this.progress = this.el.appendChild(createDom("ul", {className: "progress"}));
this.actions = this.el.appendChild(createDom("div", {className: "actions"}));
Expand All @@ -67,7 +67,9 @@ Reporter.extend({
if (action.description) {
this.actions.appendChild(createDom("div",
{className: "header", style: "padding-left:" + getSpacing(action), "data-it-actionName": action.get("fullName")},
action.description
createDom("a", {
href: "?filter=" + encodeURIComponent(action.get("fullName"))
}, action.description)
));
}
},
Expand All @@ -76,7 +78,9 @@ Reporter.extend({
var summary = action.get("summary");
this.actions.appendChild(createDom("div",
{className: "pending", style: "padding-left:" + getSpacing(action), "data-it-actionName": action.get("fullName")},
format(" %s, (%dms)", action.description, summary.duration)
createDom("a", {
href: "?filter=" + encodeURIComponent(action.get("fullName"))
}, format(" %s, (%dms)", action.description, summary.duration))
));
updateActionStatus(action, summary.status);
return this;
Expand Down
12 changes: 12 additions & 0 deletions lib/browser/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,24 @@
* @return {comb.Promise} a promise that is resolved once all tests are done running.
*/
run: function run(filter) {
var filter;
if (typeof window !== "undefined") {
try {
it.reporter("html", "it");
} catch (e) {
it.reporter("tap");
}
var paramStr = window.location.search.substring(1);
var params = {};
if (paramStr.length > 0) {
_(paramStr.split('&')).forEach(function (part) {
var p = part.split('=');
params[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
});
}
if (params.hasOwnProperty("filter")) {
filter = params.filter;
}
} else {
it.reporter("tap");
}
Expand Down
1 change: 1 addition & 0 deletions lib/interfaces/common/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ EventEmitter.extend({
ret = this._static.clone(this, this.description, {
sub: this.sub,
"filtered": this.sub ? false : true,
parent: this.parent,
__ba: this.__ba.slice(0),
__aa: this.__ba.slice(0),
"__shoulds": _(this.__shoulds).map(function (action) {
Expand Down

0 comments on commit 13202f6

Please sign in to comment.