Skip to content

Commit

Permalink
chore(wdpromise): prefer wdpromise.when to wdpromise.fulfilled (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelin committed Jan 27, 2017
1 parent 7cb9739 commit af635fa
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {

let runWaitForAngularScript: () => wdpromise.Promise<any> = () => {
if (this.plugins_.skipAngularStability() || this.bpClient) {
return wdpromise.fulfilled();
return wdpromise.when(null);
} else {
// Need to wrap this so that we read rootEl in the control flow, not synchronously.
return this.angularAppRoot().then((rootEl: string) => {
Expand Down Expand Up @@ -755,7 +755,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
'return window.NG_PENDING_TIMEOUTS',
'Protractor.waitForAngular() - getting pending timeouts' + description);
} else {
pendingTimeoutsPromise = wdpromise.fulfilled({});
pendingTimeoutsPromise = wdpromise.when({});
}
let pendingHttpsPromise = this.executeScriptWithDescription(
clientSideScripts.getPendingHttpRequests,
Expand Down Expand Up @@ -1209,7 +1209,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
pause(opt_debugPort?: number): wdpromise.Promise<any> {
if (this.debugHelper.isAttached()) {
logger.info('Encountered browser.pause(), but debugger already attached.');
return wdpromise.fulfilled(true);
return wdpromise.when(true);
}
let debuggerClientPath = __dirname + '/debugger/clients/wddebugger.js';
let onStartFn = (firstTime: boolean) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class DebugHelper {
res = 'Error while evaluating command: ' + e;
}
if (!wdpromise.isPromise(res)) {
res = wdpromise.fulfilled(res);
res = wdpromise.when(res);
}

return res.then((res: any) => {
Expand Down Expand Up @@ -237,7 +237,7 @@ export class DebugHelper {
*/
private validatePortAvailability_(port: number): wdpromise.Promise<boolean> {
if (this.debuggerValidated_) {
return wdpromise.fulfilled(false);
return wdpromise.when(false);
}

let doneDeferred = wdpromise.defer();
Expand Down
4 changes: 2 additions & 2 deletions lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ export class ElementArrayFinder extends WebdriverWebElement {
* value of the accumulator.
*/
reduce(reduceFn: Function, initialValue: any): wdpromise.Promise<any> {
let valuePromise = wdpromise.fulfilled(initialValue);
let valuePromise = wdpromise.when(initialValue);
return this.asElementFinders_().then((arr: ElementFinder[]) => {
return arr.reduce((valuePromise: any, elementFinder: ElementFinder, index: number) => {
return valuePromise.then((value: any) => {
Expand Down Expand Up @@ -863,7 +863,7 @@ export class ElementFinder extends WebdriverWebElement {
static fromWebElement_(browser: ProtractorBrowser, webElem: WebElement, locator?: Locator):
ElementFinder {
let getWebElements = () => {
return wdpromise.fulfilled([webElem]);
return wdpromise.when([webElem]);
};
return new ElementArrayFinder(browser, getWebElements, locator).toElementFinder_();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export class Runner extends EventEmitter {
});

browser_.getProcessedConfig = () => {
return wdpromise.fulfilled(config);
return wdpromise.when(config);
};

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

0 comments on commit af635fa

Please sign in to comment.