keeping track of passed expectations
This commit is contained in:
committed by
Sheel Choksi
parent
e1e49e8292
commit
5f34be446c
@@ -263,16 +263,19 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: []
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
};
|
||||
}
|
||||
|
||||
Spec.prototype.addExpectationResult = function(passed, data) {
|
||||
this.expectCalled = true;
|
||||
var expectationResult = this.expectationResultFactory(data);
|
||||
if (passed) {
|
||||
return;
|
||||
this.result.passedExpectations.push(expectationResult);
|
||||
} else {
|
||||
this.result.failedExpectations.push(expectationResult);
|
||||
}
|
||||
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
||||
};
|
||||
|
||||
Spec.prototype.expect = function(actual) {
|
||||
|
||||
@@ -175,7 +175,8 @@ describe("Spec", function() {
|
||||
status: 'pending',
|
||||
description: 'with a spec',
|
||||
fullName: 'a suite with a spec',
|
||||
failedExpectations: []
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
});
|
||||
});
|
||||
|
||||
@@ -212,6 +213,23 @@ describe("Spec", function() {
|
||||
expect(spec.status()).toBe('failed');
|
||||
});
|
||||
|
||||
it("keeps track of passed and failed expectations", function() {
|
||||
var resultCallback = jasmine.createSpy('resultCallback'),
|
||||
spec = new j$.Spec({
|
||||
fn: jasmine.createSpy("spec body"),
|
||||
expectationResultFactory: function (data) { return data; },
|
||||
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
||||
resultCallback: resultCallback
|
||||
});
|
||||
spec.addExpectationResult(true, 'expectation1');
|
||||
spec.addExpectationResult(false, 'expectation2');
|
||||
|
||||
spec.execute();
|
||||
|
||||
expect(resultCallback.calls.first().args[0].passedExpectations).toEqual(['expectation1']);
|
||||
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual(['expectation2']);
|
||||
});
|
||||
|
||||
it("can return its full name", function() {
|
||||
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
|
||||
|
||||
|
||||
@@ -165,7 +165,8 @@ describe("New HtmlReporter", function() {
|
||||
reporter.specDone({
|
||||
id: 345,
|
||||
status: "failed",
|
||||
failedExpectations: []
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
});
|
||||
|
||||
var specEl = container.querySelector(".symbol-summary li");
|
||||
@@ -289,7 +290,8 @@ describe("New HtmlReporter", function() {
|
||||
description: "with a failing spec",
|
||||
fullName: "A Suite inner with a failing spec",
|
||||
status: "failed",
|
||||
failedExpectations: []
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
};
|
||||
reporter.specStarted(specResult);
|
||||
reporter.specDone(specResult);
|
||||
|
||||
@@ -23,16 +23,19 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: []
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
};
|
||||
}
|
||||
|
||||
Spec.prototype.addExpectationResult = function(passed, data) {
|
||||
this.expectCalled = true;
|
||||
var expectationResult = this.expectationResultFactory(data);
|
||||
if (passed) {
|
||||
return;
|
||||
this.result.passedExpectations.push(expectationResult);
|
||||
} else {
|
||||
this.result.failedExpectations.push(expectationResult);
|
||||
}
|
||||
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
||||
};
|
||||
|
||||
Spec.prototype.expect = function(actual) {
|
||||
|
||||
Reference in New Issue
Block a user