Refactored TrivialReporter to handle duplicate suite names properly
This commit is contained in:
parent
1154fcaf3b
commit
0539251fe6
|
@ -58,10 +58,10 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||||
this.suiteDivs[suite.getFullName()] = suiteDiv;
|
this.suiteDivs[suite.id] = suiteDiv;
|
||||||
var parentDiv = this.outerDiv;
|
var parentDiv = this.outerDiv;
|
||||||
if (suite.parentSuite) {
|
if (suite.parentSuite) {
|
||||||
parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
|
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||||
}
|
}
|
||||||
parentDiv.appendChild(suiteDiv);
|
parentDiv.appendChild(suiteDiv);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
||||||
status = 'skipped';
|
status = 'skipped';
|
||||||
}
|
}
|
||||||
this.suiteDivs[suite.getFullName()].className += " " + status;
|
this.suiteDivs[suite.id].className += " " + status;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||||
|
@ -150,7 +150,7 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||||
specDiv.appendChild(messagesDiv);
|
specDiv.appendChild(messagesDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
|
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.log = function() {
|
jasmine.TrivialReporter.prototype.log = function() {
|
||||||
|
|
|
@ -108,12 +108,10 @@ describe("TrivialReporter", function() {
|
||||||
getItems: function() {
|
getItems: function() {
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
var suite1 = new jasmine.Suite(env, "suite 1", null, null);
|
||||||
|
|
||||||
spec = {
|
spec = {
|
||||||
suite: {
|
suite: suite1,
|
||||||
getFullName: function() {
|
|
||||||
return "suite 1";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getFullName: function() {
|
getFullName: function() {
|
||||||
return "foo";
|
return "foo";
|
||||||
},
|
},
|
||||||
|
@ -125,7 +123,7 @@ describe("TrivialReporter", function() {
|
||||||
trivialReporter.reportRunnerStarting({
|
trivialReporter.reportRunnerStarting({
|
||||||
env: env,
|
env: env,
|
||||||
suites: function() {
|
suites: function() {
|
||||||
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
return [ suite1 ];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -175,4 +173,36 @@ describe("TrivialReporter", function() {
|
||||||
expect(errorDiv.innerHTML).toEqual("this is a multipart log message");
|
expect(errorDiv.innerHTML).toEqual("this is a multipart log message");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("duplicate example names", function() {
|
||||||
|
it("should report failures correctly", function() {
|
||||||
|
var suite1 = env.describe("suite", function() {
|
||||||
|
env.it("will have log messages", function() {
|
||||||
|
this.log("this one fails!");
|
||||||
|
this.expect(true).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var suite2 = env.describe("suite", function() {
|
||||||
|
env.it("will have log messages", function() {
|
||||||
|
this.log("this one passes!");
|
||||||
|
this.expect(true).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(trivialReporter);
|
||||||
|
env.execute();
|
||||||
|
|
||||||
|
var divs = body.getElementsByTagName("div");
|
||||||
|
var passedSpecDiv = findElement(divs, 'suite passed');
|
||||||
|
expect(passedSpecDiv.className).toEqual('suite passed');
|
||||||
|
expect(passedSpecDiv.innerHTML).toContain("this one passes!");
|
||||||
|
expect(passedSpecDiv.innerHTML).not.toContain("this one fails!");
|
||||||
|
|
||||||
|
var failedSpecDiv = findElement(divs, 'suite failed');
|
||||||
|
expect(failedSpecDiv.className).toEqual('suite failed');
|
||||||
|
expect(failedSpecDiv.innerHTML).toContain("this one fails!");
|
||||||
|
expect(failedSpecDiv.innerHTML).not.toContain("this one passes!");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue