UNPKG

@assert-equals/dappdriver

Version:

DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion

82 lines (81 loc) 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SignInRequest = void 0; const constants_1 = require("../../constants"); const metamask_1 = require("../../metamask"); const rainbow_1 = require("../../rainbow"); const dapp_driver_1 = require("../../session/dapp-driver"); const zerion_1 = require("../../zerion"); /** * * * @export * @class SignInRequest * @implements {IConfirmation} */ class SignInRequest { url; title; signInRequest; constructor() { switch (dapp_driver_1.DappDriver.Instance.Wallet) { case constants_1.METAMASK: case constants_1.METAMASK_FLASK: this.signInRequest = new metamask_1.SignInRequest(); break; case constants_1.RAINBOW: this.signInRequest = new rainbow_1.SignInRequest(); break; case constants_1.ZERION: this.signInRequest = new zerion_1.SignInRequest(); break; } this.url = this.signInRequest.url; this.title = this.signInRequest.title; } async callIfMethodExists(methodName, args = []) { return await this.signInRequest[methodName](...args); } async accept(page) { if (page) { return await this.callIfMethodExists('accept', [page]); } else { return await this.callIfMethodExists('accept'); } } /** * * * @return {*} {Promise<any[]>} * @memberof SignInRequest */ async getAllWindowHandles() { return await this.callIfMethodExists('getAllWindowHandles'); } async reject(page) { if (page) { return await this.callIfMethodExists('reject', [page]); } else { return await this.callIfMethodExists('reject'); } } async switchToMainWindow(page) { if (page) { return await this.callIfMethodExists('switchToMainWindow', [page]); } else { return await this.callIfMethodExists('switchToMainWindow'); } } async switchToWindow(nameOrHandle, page) { if (page) { return await this.callIfMethodExists('switchToWindow', [nameOrHandle, page]); } else { return await this.callIfMethodExists('switchToWindow', [nameOrHandle]); } } } exports.SignInRequest = SignInRequest;