@theia-extension-tester/tests
Version:
Tests for theia-extension-tester package.
130 lines • 6.14 kB
JavaScript
;
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 MAIN_FILE = 'quarkus-quickstarts/Untitled.txt';
const ALTERNATIVE_FILE = 'quarkus-quickstarts/Alternative.txt';
const MAIN_FILE_TITLE = path.basename(MAIN_FILE);
const ALTERNATIVE_FILE_TITLE = path.basename(ALTERNATIVE_FILE);
describe('EditorView', function () {
this.timeout(40000);
let editorView;
let tree;
before(function () {
return __awaiter(this, void 0, void 0, function* () {
editorView = new page_objects_1.EditorView();
yield editorView.closeAllEditors();
tree = yield File_1.getExplorerSection();
yield File_1.deleteFiles(MAIN_FILE, ALTERNATIVE_FILE);
yield tree.createFile(MAIN_FILE);
yield tree.createFile(ALTERNATIVE_FILE);
});
});
beforeEach(function () {
return __awaiter(this, void 0, void 0, function* () {
tree = yield File_1.getExplorerSection();
yield editorView.closeAllEditors();
});
});
after(function () {
return __awaiter(this, void 0, void 0, function* () {
yield File_1.deleteFiles(MAIN_FILE, ALTERNATIVE_FILE);
yield editorView.closeAllEditors();
});
});
it('openEditor', function () {
return __awaiter(this, void 0, void 0, function* () {
yield tree.openFile(MAIN_FILE);
yield tree.openFile(ALTERNATIVE_FILE);
let active = yield editorView.getActiveTab();
chai_1.expect(yield active.getTitle()).equals(ALTERNATIVE_FILE_TITLE);
yield openEditor(MAIN_FILE_TITLE, editorView);
active = yield editorView.getActiveTab();
chai_1.expect(yield active.getTitle()).equals(MAIN_FILE_TITLE);
});
});
it('closeEditor', function () {
return __awaiter(this, void 0, void 0, function* () {
yield tree.openFile(MAIN_FILE);
const active = yield editorView.getActiveTab();
chai_1.expect(yield active.getTitle()).equals(MAIN_FILE_TITLE);
yield closeEditor(MAIN_FILE_TITLE, editorView);
chai_1.expect(yield editorView.getOpenEditorTitles()).not.to.include(MAIN_FILE_TITLE);
});
});
it('closeAllEditors', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield editorView.getOpenTabs()).to.be.empty;
yield tree.openFile(MAIN_FILE);
yield tree.openFile(ALTERNATIVE_FILE);
chai_1.expect(yield editorView.getOpenTabs()).length(2);
yield editorView.closeAllEditors();
chai_1.expect(yield editorView.getOpenTabs()).to.be.empty;
});
});
it('getOpenEditorTitles', function () {
return __awaiter(this, void 0, void 0, function* () {
yield tree.openFile(MAIN_FILE);
yield tree.openFile(ALTERNATIVE_FILE);
chai_1.expect(yield editorView.getOpenEditorTitles()).to.include.members([MAIN_FILE_TITLE, ALTERNATIVE_FILE_TITLE]);
});
});
it('getTabByTitle', function () {
return __awaiter(this, void 0, void 0, function* () {
yield tree.openFile(MAIN_FILE);
yield tree.openFile(ALTERNATIVE_FILE);
chai_1.expect(yield editorView.getOpenEditorTitles()).to.include.members([MAIN_FILE_TITLE, ALTERNATIVE_FILE_TITLE]);
const tab = yield editorView.getTabByTitle(MAIN_FILE_TITLE);
chai_1.expect(yield tab.getTitle()).equals(MAIN_FILE_TITLE);
});
});
it('getOpenTabs', function () {
return __awaiter(this, void 0, void 0, function* () {
yield tree.openFile(MAIN_FILE);
yield tree.openFile(ALTERNATIVE_FILE);
chai_1.expect(yield editorView.getOpenEditorTitles()).to.include.members([MAIN_FILE_TITLE, ALTERNATIVE_FILE_TITLE]);
const tabs = yield editorView.getOpenTabs();
const titles = yield Promise.all(tabs.map((tab) => tab.getTitle()));
chai_1.expect(titles).to.include.members([MAIN_FILE_TITLE, ALTERNATIVE_FILE_TITLE]);
});
});
it('getActiveTab', function () {
return __awaiter(this, void 0, void 0, function* () {
yield tree.openFile(MAIN_FILE);
yield tree.openFile(ALTERNATIVE_FILE);
chai_1.expect(yield editorView.getOpenEditorTitles()).to.include.members([MAIN_FILE_TITLE, ALTERNATIVE_FILE_TITLE]);
const active = yield editorView.getActiveTab();
chai_1.expect(yield active.getTitle()).equals(ALTERNATIVE_FILE_TITLE);
});
});
it.skip('getEditorGroups', function () {
return __awaiter(this, void 0, void 0, function* () {
});
});
it.skip('getEditorGroup', function () {
return __awaiter(this, void 0, void 0, function* () {
});
});
});
function openEditor(file, editorView) {
return __awaiter(this, void 0, void 0, function* () {
yield editorView.openEditor(path.basename(file));
});
}
function closeEditor(file, editorView) {
return __awaiter(this, void 0, void 0, function* () {
yield editorView.closeEditor(path.basename(file));
});
}
//# sourceMappingURL=EditorView.test.js.map