UNPKG

@theia-extension-tester/tests

Version:

Tests for theia-extension-tester package.

115 lines 4.96 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const page_objects_1 = require("@theia-extension-tester/page-objects"); const File_1 = require("./utils/File"); const path = require("path"); const FILE = 'quarkus-quickstarts/Alternative.txt'; describe('ContextMenu', function () { this.timeout(40000); let menu; let editor; let tree; before(function () { return __awaiter(this, void 0, void 0, function* () { yield File_1.deleteFiles(FILE); tree = yield File_1.getExplorerSection(); editor = (yield tree.createFile(FILE)); chai_1.expect(yield editor.getTitle()).equals(path.basename(FILE)); yield editor.setTextAtLine(1, 'Hello world'); yield editor.sendKeys(page_objects_1.Key.ENTER); yield editor.sendKeys('Hello world 2'); yield editor.sendKeys(page_objects_1.Key.ENTER); }); }); afterEach(function () { return __awaiter(this, void 0, void 0, function* () { if (menu instanceof page_objects_1.ContextMenu) { yield menu.close(); } }); }); after(function () { return __awaiter(this, void 0, void 0, function* () { yield editor.save(); yield new page_objects_1.EditorView().closeAllEditors(); yield File_1.deleteFiles(FILE); }); }); it('getItem', function () { return __awaiter(this, void 0, void 0, function* () { menu = (yield editor.openContextMenu()); chai_1.expect(menu).not.to.be.undefined; yield menu.getItem('Peek'); }); }); it('getLabel', function () { return __awaiter(this, void 0, void 0, function* () { menu = (yield editor.openContextMenu()); chai_1.expect(menu).not.to.be.undefined; const peek = yield menu.getItem('Refactor...'); chai_1.expect(yield peek.getLabel()).equals('Refactor...'); }); }); it('getItems', function () { return __awaiter(this, void 0, void 0, function* () { menu = (yield editor.openContextMenu()); chai_1.expect(menu).not.to.be.undefined; yield menu.getItem('Peek'); const items = yield menu.getItems(); const labels = yield Promise.all(items.map((item) => item.getLabel())); chai_1.expect(labels).to.include.members(['Peek', 'Refactor...', 'Redo', 'Undo', 'Copy']); }); }); it('hasItem', function () { return __awaiter(this, void 0, void 0, function* () { menu = (yield editor.openContextMenu()); chai_1.expect(menu).not.to.be.undefined; yield menu.getItem('Peek'); chai_1.expect(yield menu.hasItem('Peek')).to.be.true; chai_1.expect(yield menu.hasItem('tester')).to.be.false; }); }); it('select', function () { return __awaiter(this, void 0, void 0, function* () { menu = new page_objects_1.TitleBar(); const subMenu = yield menu.select('File'); const items = yield subMenu.getItems(); const labels = yield Promise.all(items.map((item) => item.getLabel())); chai_1.expect(labels).to.include.members([ 'Settings', 'Save', 'Save All', 'Open...', 'New Folder' ]); try { const item = yield subMenu.select('Settings', 'Open Preferences'); chai_1.expect(item).to.be.undefined; const tab = yield new page_objects_1.EditorView().getTabByTitle('Preferences'); yield tab.close(); } finally { menu = undefined; } }); }); it('close', function () { return __awaiter(this, void 0, void 0, function* () { const menu = yield editor.openContextMenu(); chai_1.expect(menu).not.to.be.undefined; yield menu.close(); chai_1.expect(yield menu.isDisplayed().catch(() => false)).to.be.false; }); }); }); //# sourceMappingURL=ContextMenu.test.js.map