Skip to content

Commit

Permalink
Removed expect/expectAsync indirection through spec/suite
Browse files Browse the repository at this point in the history
  • Loading branch information
sgravrock committed Jul 15, 2023
1 parent f8e4ea8 commit 59600a1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 40 deletions.
28 changes: 8 additions & 20 deletions lib/jasmine-core/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,6 @@ getJasmineRequireObj().Spec = function(j$) {
this.result.properties[key] = value;
};

Spec.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};

Spec.prototype.expectAsync = function(actual) {
return this.asyncExpectationFactory(actual, this);
};

Spec.prototype.execute = function(
queueRunnerFactory,
onComplete,
Expand Down Expand Up @@ -1904,23 +1896,27 @@ getJasmineRequireObj().Env = function(j$) {
};

this.expect = function(actual) {
if (!runner.currentRunable()) {
const runable = runner.currentRunable();

if (!runable) {
throw new Error(
"'expect' was used when there was no current spec, this could be because an asynchronous test timed out"
);
}

return runner.currentRunable().expect(actual);
return runable.expectationFactory(actual, runable);
};

this.expectAsync = function(actual) {
if (!runner.currentRunable()) {
const runable = runner.currentRunable();

if (!runable) {
throw new Error(
"'expectAsync' was used when there was no current spec, this could be because an asynchronous test timed out"
);
}

return runner.currentRunable().expectAsync(actual);
return runable.asyncExpectationFactory(actual, runable);
};

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

Suite.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};

Suite.prototype.expectAsync = function(actual) {
return this.asyncExpectationFactory(actual, this);
};

Suite.prototype.getFullName = function() {
const fullName = [];
for (
Expand Down
12 changes: 8 additions & 4 deletions src/core/Env.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,23 +767,27 @@ getJasmineRequireObj().Env = function(j$) {
};

this.expect = function(actual) {
if (!runner.currentRunable()) {
const runable = runner.currentRunable();

if (!runable) {
throw new Error(
"'expect' was used when there was no current spec, this could be because an asynchronous test timed out"
);
}

return runner.currentRunable().expect(actual);
return runable.expectationFactory(actual, runable);
};

this.expectAsync = function(actual) {
if (!runner.currentRunable()) {
const runable = runner.currentRunable();

if (!runable) {
throw new Error(
"'expectAsync' was used when there was no current spec, this could be because an asynchronous test timed out"
);
}

return runner.currentRunable().expectAsync(actual);
return runable.asyncExpectationFactory(actual, runable);
};

this.beforeEach = function(beforeEachFunction, timeout) {
Expand Down
8 changes: 0 additions & 8 deletions src/core/Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ getJasmineRequireObj().Spec = function(j$) {
this.result.properties[key] = value;
};

Spec.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};

Spec.prototype.expectAsync = function(actual) {
return this.asyncExpectationFactory(actual, this);
};

Spec.prototype.execute = function(
queueRunnerFactory,
onComplete,
Expand Down
8 changes: 0 additions & 8 deletions src/core/Suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ getJasmineRequireObj().Suite = function(j$) {
this.result.properties[key] = value;
};

Suite.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};

Suite.prototype.expectAsync = function(actual) {
return this.asyncExpectationFactory(actual, this);
};

Suite.prototype.getFullName = function() {
const fullName = [];
for (
Expand Down

0 comments on commit 59600a1

Please sign in to comment.