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