Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 0553176

Browse files
authored
chore(wdpromise): prefer wdpromise.when to wdpromise.fulfilled (#4018)
Closes #3903
1 parent f11fece commit 0553176

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/browser.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
613613

614614
let runWaitForAngularScript: () => wdpromise.Promise<any> = () => {
615615
if (this.plugins_.skipAngularStability() || this.bpClient) {
616-
return wdpromise.fulfilled();
616+
return wdpromise.when(null);
617617
} else {
618618
return this.executeAsyncScript_(
619619
clientSideScripts.waitForAngular, 'Protractor.waitForAngular()' + description,
@@ -671,7 +671,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
671671
'return window.NG_PENDING_TIMEOUTS',
672672
'Protractor.waitForAngular() - getting pending timeouts' + description);
673673
} else {
674-
pendingTimeoutsPromise = wdpromise.fulfilled({});
674+
pendingTimeoutsPromise = wdpromise.when({});
675675
}
676676
let pendingHttpsPromise = this.executeScriptWithDescription(
677677
clientSideScripts.getPendingHttpRequests,
@@ -1125,7 +1125,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
11251125
pause(opt_debugPort?: number): wdpromise.Promise<any> {
11261126
if (this.debugHelper.isAttached()) {
11271127
logger.info('Encountered browser.pause(), but debugger already attached.');
1128-
return wdpromise.fulfilled(true);
1128+
return wdpromise.when(true);
11291129
}
11301130
let debuggerClientPath = __dirname + '/debugger/clients/wddebugger.js';
11311131
let onStartFn = (firstTime: boolean) => {

lib/debugger.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class DebugHelper {
169169
res = 'Error while evaluating command: ' + e;
170170
}
171171
if (!wdpromise.isPromise(res)) {
172-
res = wdpromise.fulfilled(res);
172+
res = wdpromise.when(res);
173173
}
174174

175175
return res.then((res: any) => {
@@ -237,7 +237,7 @@ export class DebugHelper {
237237
*/
238238
private validatePortAvailability_(port: number): wdpromise.Promise<boolean> {
239239
if (this.debuggerValidated_) {
240-
return wdpromise.fulfilled(false);
240+
return wdpromise.when(false);
241241
}
242242

243243
let doneDeferred = wdpromise.defer();

lib/element.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ export class ElementArrayFinder extends WebdriverWebElement {
689689
* value of the accumulator.
690690
*/
691691
reduce(reduceFn: Function, initialValue: any): wdpromise.Promise<any> {
692-
let valuePromise = wdpromise.fulfilled(initialValue);
692+
let valuePromise = wdpromise.when(initialValue);
693693
return this.asElementFinders_().then((arr: ElementFinder[]) => {
694694
return arr.reduce((valuePromise: any, elementFinder: ElementFinder, index: number) => {
695695
return valuePromise.then((value: any) => {
@@ -863,7 +863,7 @@ export class ElementFinder extends WebdriverWebElement {
863863
static fromWebElement_(browser: ProtractorBrowser, webElem: WebElement, locator?: Locator):
864864
ElementFinder {
865865
let getWebElements = () => {
866-
return wdpromise.fulfilled([webElem]);
866+
return wdpromise.when([webElem]);
867867
};
868868
return new ElementArrayFinder(browser, getWebElements, locator).toElementFinder_();
869869
}

lib/runner.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export class Runner extends EventEmitter {
258258
});
259259

260260
browser_.getProcessedConfig = () => {
261-
return wdpromise.fulfilled(config);
261+
return wdpromise.when(config);
262262
};
263263

264264
browser_.forkNewDriverInstance = (opt_useSameUrl: boolean, opt_copyMockModules: boolean) => {

0 commit comments

Comments
 (0)