appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
119 lines • 4.84 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const driver_1 = require("../../../lib/driver");
const chai_1 = __importStar(require("chai"));
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
chai_1.default.use(chai_as_promised_1.default);
describe('context', function () {
describe('onPageChange', function () {
const pageChangeNotification = {
appIdKey: '5191',
pageArray: [
{
id: 1,
title: 'Appium/welcome',
url: 'http://127.0.0.1:4443/welcome',
isKey: true,
},
{
id: 3,
title: 'Bing!',
url: 'https://www.bing.com/',
isKey: false,
},
{
id: 4,
title: 'Google',
url: 'https://www.google.com/?client=safari&channel=iphone_bm',
isKey: true,
},
{
id: 5,
title: '',
url: 'about:blank',
isKey: false,
},
],
};
it('should call select page if a new page is introduced and that page is not blacklisted', async function () {
const driver = new driver_1.XCUITestDriver({});
driver.curContext = '5191.5';
driver.contexts = ['5191.5', '5191.3', '5191.4'];
/** @type {undefined|(string|number)[]} */
let selectPageArgs;
const remoteMock = {
isConnected: true,
selectPage: (...args) => {
selectPageArgs = args;
return { catch: () => { } };
},
};
driver._remote = remoteMock;
driver.opts.safariIgnoreWebHostnames =
'www.google.com, www.bing.com,yahoo.com, about:blank, ';
await driver.onPageChange(pageChangeNotification);
(0, chai_1.expect)(selectPageArgs).to.eql(['5191', 1]);
});
it('should not call selectPage if a new page is introduced and that page is blacklisted', async function () {
const driver = new driver_1.XCUITestDriver({});
driver.curContext = '5191.1';
const testContexts = [
['5191.1', '5191.3', '5191.4'],
['5191.1', '5191.3', '5191.5'],
];
for (const testContext of testContexts) {
driver.contexts = testContext;
let selectPageArgs = null;
const remoteMock = {
isConnected: true,
selectPage: (...args) => {
selectPageArgs = args;
return { catch: () => { } };
},
};
driver._remote = remoteMock;
driver.opts.safariIgnoreWebHostnames =
'www.google.com, www.bing.com,www.yahoo.com, about:blank, ';
await driver.onPageChange(pageChangeNotification);
(0, chai_1.expect)(selectPageArgs).to.be.null;
}
});
});
});
//# sourceMappingURL=context-specs.js.map