UNPKG

@assert-equals/dappdriver

Version:

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

62 lines (61 loc) 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Approve = void 0; const dapp_driver_1 = require("../../session/dapp-driver"); class Approve { url; title; approve; constructor() { this.approve = new dapp_driver_1.DappDriver.Instance.Extension.pages.Approve(); this.url = this.approve.url; this.title = this.approve.title; } async callIfMethodExists(methodName, args = []) { return await this.approve[methodName](...args); } /** * * * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof Approve */ async accept(page) { return await this.callIfMethodExists('accept', [page]); } /** * * * @return {*} {Promise<any[]>} * @memberof Approve */ async getAllWindowHandles() { return await this.callIfMethodExists('getAllWindowHandles'); } /** * * * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof Approve */ async reject(page) { return await this.callIfMethodExists('reject', [page]); } /** * * * @template TPage * @param {*} nameOrHandle * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof Approve */ async switchToWindow(page) { return await this.callIfMethodExists('switchToWindow', [page]); } } exports.Approve = Approve;