Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

keeping track of passed expectations

  • Loading branch information...
commit 5f34be446c0a8048cfb40a04636dcd49851452f6 1 parent e1e49e8
Alex Treppass alextreppass authored sheelc committed
9 lib/jasmine-core/jasmine.js
View
@@ -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) {
20 spec/core/SpecSpec.js
View
@@ -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');
6 spec/html/HtmlReporterSpec.js
View
@@ -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);
9 src/core/Spec.js
View
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.