Skip to content

Commit 59600a1

Browse files
committed
Removed expect/expectAsync indirection through spec/suite
1 parent f8e4ea8 commit 59600a1

File tree

4 files changed

+16
-40
lines changed

4 files changed

+16
-40
lines changed

lib/jasmine-core/jasmine.js

+8-20
Original file line numberDiff line numberDiff line change
@@ -809,14 +809,6 @@ getJasmineRequireObj().Spec = function(j$) {
809809
this.result.properties[key] = value;
810810
};
811811

812-
Spec.prototype.expect = function(actual) {
813-
return this.expectationFactory(actual, this);
814-
};
815-
816-
Spec.prototype.expectAsync = function(actual) {
817-
return this.asyncExpectationFactory(actual, this);
818-
};
819-
820812
Spec.prototype.execute = function(
821813
queueRunnerFactory,
822814
onComplete,
@@ -1904,23 +1896,27 @@ getJasmineRequireObj().Env = function(j$) {
19041896
};
19051897

19061898
this.expect = function(actual) {
1907-
if (!runner.currentRunable()) {
1899+
const runable = runner.currentRunable();
1900+
1901+
if (!runable) {
19081902
throw new Error(
19091903
"'expect' was used when there was no current spec, this could be because an asynchronous test timed out"
19101904
);
19111905
}
19121906

1913-
return runner.currentRunable().expect(actual);
1907+
return runable.expectationFactory(actual, runable);
19141908
};
19151909

19161910
this.expectAsync = function(actual) {
1917-
if (!runner.currentRunable()) {
1911+
const runable = runner.currentRunable();
1912+
1913+
if (!runable) {
19181914
throw new Error(
19191915
"'expectAsync' was used when there was no current spec, this could be because an asynchronous test timed out"
19201916
);
19211917
}
19221918

1923-
return runner.currentRunable().expectAsync(actual);
1919+
return runable.asyncExpectationFactory(actual, runable);
19241920
};
19251921

19261922
this.beforeEach = function(beforeEachFunction, timeout) {
@@ -9755,14 +9751,6 @@ getJasmineRequireObj().Suite = function(j$) {
97559751
this.result.properties[key] = value;
97569752
};
97579753

9758-
Suite.prototype.expect = function(actual) {
9759-
return this.expectationFactory(actual, this);
9760-
};
9761-
9762-
Suite.prototype.expectAsync = function(actual) {
9763-
return this.asyncExpectationFactory(actual, this);
9764-
};
9765-
97669754
Suite.prototype.getFullName = function() {
97679755
const fullName = [];
97689756
for (

src/core/Env.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -767,23 +767,27 @@ getJasmineRequireObj().Env = function(j$) {
767767
};
768768

769769
this.expect = function(actual) {
770-
if (!runner.currentRunable()) {
770+
const runable = runner.currentRunable();
771+
772+
if (!runable) {
771773
throw new Error(
772774
"'expect' was used when there was no current spec, this could be because an asynchronous test timed out"
773775
);
774776
}
775777

776-
return runner.currentRunable().expect(actual);
778+
return runable.expectationFactory(actual, runable);
777779
};
778780

779781
this.expectAsync = function(actual) {
780-
if (!runner.currentRunable()) {
782+
const runable = runner.currentRunable();
783+
784+
if (!runable) {
781785
throw new Error(
782786
"'expectAsync' was used when there was no current spec, this could be because an asynchronous test timed out"
783787
);
784788
}
785789

786-
return runner.currentRunable().expectAsync(actual);
790+
return runable.asyncExpectationFactory(actual, runable);
787791
};
788792

789793
this.beforeEach = function(beforeEachFunction, timeout) {

src/core/Spec.js

-8
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ getJasmineRequireObj().Spec = function(j$) {
7070
this.result.properties[key] = value;
7171
};
7272

73-
Spec.prototype.expect = function(actual) {
74-
return this.expectationFactory(actual, this);
75-
};
76-
77-
Spec.prototype.expectAsync = function(actual) {
78-
return this.asyncExpectationFactory(actual, this);
79-
};
80-
8173
Spec.prototype.execute = function(
8274
queueRunnerFactory,
8375
onComplete,

src/core/Suite.js

-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ getJasmineRequireObj().Suite = function(j$) {
2828
this.result.properties[key] = value;
2929
};
3030

31-
Suite.prototype.expect = function(actual) {
32-
return this.expectationFactory(actual, this);
33-
};
34-
35-
Suite.prototype.expectAsync = function(actual) {
36-
return this.asyncExpectationFactory(actual, this);
37-
};
38-
3931
Suite.prototype.getFullName = function() {
4032
const fullName = [];
4133
for (

0 commit comments

Comments
 (0)