Skip to content

Commit 7eb23dd

Browse files
authored
Remove now unnecessary finishPromised() from lib/test.js
1 parent 276c16a commit 7eb23dd

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

Diff for: lib/test.js

+15-21
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,12 @@ class Test {
525525
waitForPendingThrowsAssertion() {
526526
return new Promise(resolve => {
527527
this.finishDueToAttributedError = () => {
528-
resolve(this.finishPromised());
528+
resolve(this.finish());
529529
};
530530

531531
this.finishDueToInactivity = () => {
532532
this.detectImproperThrows();
533-
resolve(this.finishPromised());
533+
resolve(this.finish());
534534
};
535535

536536
// Wait up to a second to see if an error can be attributed to the
@@ -575,7 +575,7 @@ class Test {
575575
}));
576576
}
577577

578-
return this.finishPromised();
578+
return this.finish();
579579
}
580580

581581
const returnedObservable = result.retval !== null && typeof result.retval === 'object' && typeof result.retval.subscribe === 'function';
@@ -598,49 +598,49 @@ class Test {
598598
if (returnedObservable || returnedPromise) {
599599
const asyncType = returnedObservable ? 'observables' : 'promises';
600600
this.saveFirstError(new Error(`Do not return ${asyncType} from tests declared via \`test.cb(…)\`. Use \`test.cb(…)\` for legacy callback APIs. When using promises, observables or async functions, use \`test(…)\`.`));
601-
return this.finishPromised();
601+
return this.finish();
602602
}
603603

604604
if (this.calledEnd) {
605-
return this.finishPromised();
605+
return this.finish();
606606
}
607607

608608
return new Promise(resolve => {
609609
this.endCallbackFinisher = () => {
610-
resolve(this.finishPromised());
610+
resolve(this.finish());
611611
};
612612

613613
this.finishDueToAttributedError = () => {
614-
resolve(this.finishPromised());
614+
resolve(this.finish());
615615
};
616616

617617
this.finishDueToTimeout = () => {
618-
resolve(this.finishPromised());
618+
resolve(this.finish());
619619
};
620620

621621
this.finishDueToInactivity = () => {
622622
this.saveFirstError(new Error('`t.end()` was never called'));
623-
resolve(this.finishPromised());
623+
resolve(this.finish());
624624
};
625625
});
626626
}
627627

628628
if (promise) {
629629
return new Promise(resolve => {
630630
this.finishDueToAttributedError = () => {
631-
resolve(this.finishPromised());
631+
resolve(this.finish());
632632
};
633633

634634
this.finishDueToTimeout = () => {
635-
resolve(this.finishPromised());
635+
resolve(this.finish());
636636
};
637637

638638
this.finishDueToInactivity = () => {
639639
const error = returnedObservable ?
640640
new Error('Observable returned by test never completed') :
641641
new Error('Promise returned by test never resolved');
642642
this.saveFirstError(error);
643-
resolve(this.finishPromised());
643+
resolve(this.finish());
644644
};
645645

646646
promise
@@ -653,14 +653,14 @@ class Test {
653653
}));
654654
}
655655
})
656-
.then(() => resolve(this.finishPromised())); // eslint-disable-line promise/prefer-await-to-then
656+
.then(() => resolve(this.finish())); // eslint-disable-line promise/prefer-await-to-then
657657
});
658658
}
659659

660-
return this.finishPromised();
660+
return this.finish();
661661
}
662662

663-
finish() {
663+
async finish() {
664664
this.finishing = true;
665665

666666
if (!this.assertError && this.pendingThrowsAssertion) {
@@ -698,12 +698,6 @@ class Test {
698698
title: this.title
699699
};
700700
}
701-
702-
finishPromised() {
703-
return new Promise(resolve => {
704-
resolve(this.finish());
705-
});
706-
}
707701
}
708702

709703
module.exports = Test;

0 commit comments

Comments
 (0)