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.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfirmTransaction = 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 ConfirmTransaction * @implements {IConfirmation} */ class ConfirmTransaction { url; title; confirmTx; constructor() { switch (dapp_driver_1.DappDriver.Instance.Wallet) { case constants_1.METAMASK: case constants_1.METAMASK_FLASK: this.confirmTx = new metamask_1.ConfirmTransaction(); break; case constants_1.RAINBOW: this.confirmTx = new rainbow_1.ConfirmTransaction(); break; case constants_1.ZERION: this.confirmTx = new zerion_1.ConfirmTransaction(); break; } this.url = this.confirmTx.url; this.title = this.confirmTx.title; } async callIfMethodExists(methodName, args = []) { return await this.confirmTx[methodName](...args); } async accept(page) { if (page) { return await this.callIfMethodExists('accept', [page]); } else { return await this.callIfMethodExists('accept'); } } /** * * * @return {*} {Promise<any[]>} * @memberof ConfirmTransaction */ 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.ConfirmTransaction = ConfirmTransaction;