@assert-equals/dappdriver
Version:
DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
75 lines (74 loc) • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Approve = 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");
class Approve {
url;
title;
approve;
constructor() {
switch (dapp_driver_1.DappDriver.Instance.Wallet) {
case constants_1.METAMASK:
case constants_1.METAMASK_FLASK:
this.approve = new metamask_1.Approve();
break;
case constants_1.RAINBOW:
this.approve = new rainbow_1.Approve();
break;
case constants_1.ZERION:
this.approve = new zerion_1.Approve();
break;
}
this.url = this.approve.url;
this.title = this.approve.title;
}
async callIfMethodExists(methodName, args = []) {
return await this.approve[methodName](...args);
}
async accept(page) {
if (page) {
return await this.callIfMethodExists('accept', [page]);
}
else {
return await this.callIfMethodExists('accept');
}
}
/**
*
*
* @return {*} {Promise<any[]>}
* @memberof Approve
*/
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.Approve = Approve;