UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

65 lines 3.17 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const sinon_1 = __importDefault(require("sinon")); const driver_1 = require("../../../lib/driver"); const node_simctl_1 = require("node-simctl"); const chai_1 = require("chai"); describe('pasteboard commands', function () { const driver = new driver_1.XCUITestDriver({}); let isSimulatorStub, setPasteboardStub, getPasteboardStub; beforeEach(function () { const simctl = new node_simctl_1.Simctl(); setPasteboardStub = sinon_1.default.stub(simctl, 'setPasteboard'); getPasteboardStub = sinon_1.default.stub(simctl, 'getPasteboard'); driver._device = { simctl }; isSimulatorStub = sinon_1.default.stub(driver, 'isSimulator'); }); afterEach(function () { isSimulatorStub.restore(); setPasteboardStub.restore(); getPasteboardStub.restore(); }); describe('real device', function () { beforeEach(function () { isSimulatorStub.returns(false); }); it('setPasteboard should not be called', async function () { // @ts-expect-error incorrect usage await (0, chai_1.expect)(driver.mobileSetPasteboard({ content: 'bla' })).to.be.rejectedWith(/can only be performed on Simulator/); (0, chai_1.expect)(setPasteboardStub.notCalled).to.be.true; }); it('getPasteboard should not be called', async function () { await (0, chai_1.expect)(driver.mobileGetPasteboard()).to.be.rejectedWith(/can only be performed on Simulator/); (0, chai_1.expect)(getPasteboardStub.notCalled).to.be.true; }); }); describe('simulator', function () { beforeEach(function () { isSimulatorStub.returns(true); }); it('setPasteboard should fail if no content is provided', async function () { // @ts-expect-error incorrect usage await (0, chai_1.expect)(driver.mobileSetPasteboard()).to.be.rejectedWith(/mandatory to set/); (0, chai_1.expect)(setPasteboardStub.notCalled).to.be.true; }); it('setPasteboard should invoke correct simctl method', async function () { const content = 'bla'; const encoding = 'latin1'; await driver.mobileSetPasteboard(content, encoding); (0, chai_1.expect)(setPasteboardStub.calledOnce).to.be.true; (0, chai_1.expect)(setPasteboardStub.firstCall.args[0]).to.eql(content); (0, chai_1.expect)(setPasteboardStub.firstCall.args[1]).to.eql(encoding); }); it('getPasteboard should invoke correct simctl method', async function () { const content = 'bla'; getPasteboardStub.returns(content); const result = await driver.mobileGetPasteboard(); (0, chai_1.expect)(getPasteboardStub.calledOnce).to.be.true; (0, chai_1.expect)(result).to.eql(content); }); }); }); //# sourceMappingURL=pasteboard-specs.js.map