@theia-extension-tester/tests
Version:
Tests for theia-extension-tester package.
159 lines • 6.96 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");
describe('ContentAssist', function () {
this.timeout(40000);
let editorView;
let tree;
let editor;
let menu;
const fileName = "quarkus-quickstarts/Editor.ts";
let filePath;
const validationItems = ['#endregion', '#region', 'for', 'forin', 'forof', 'ctor', 'function', 'get'];
before(function () {
return __awaiter(this, void 0, void 0, function* () {
editorView = new page_objects_1.EditorView();
tree = yield File_1.getExplorerSection();
yield editorView.closeAllEditors();
yield File_1.deleteFiles(fileName);
editor = (yield tree.createFile(fileName));
filePath = yield editor.getFilePath();
});
});
beforeEach(function () {
return __awaiter(this, void 0, void 0, function* () {
yield editor.clearText();
menu = (yield editor.toggleContentAssist(true));
yield menu.getDriver().wait(() => menu === null || menu === void 0 ? void 0 : menu.isLoaded(), this.timeout() - 3000, 'Content assist did not load.');
chai_1.expect(menu).not.to.be.undefined;
chai_1.expect(validationItems).not.to.be.empty;
chai_1.expect(editor).not.to.be.undefined;
chai_1.expect(tree).not.to.be.undefined;
chai_1.expect(editorView).not.to.be.undefined;
});
});
afterEach(function () {
return __awaiter(this, void 0, void 0, function* () {
yield (menu === null || menu === void 0 ? void 0 : menu.close());
menu = undefined;
});
});
after(function () {
return __awaiter(this, void 0, void 0, function* () {
if (filePath) {
yield editor.save();
yield File_1.deleteFiles(filePath);
}
yield (menu === null || menu === void 0 ? void 0 : menu.close());
});
});
it('getItem', function () {
return __awaiter(this, void 0, void 0, function* () {
yield editor.setText('f');
const item = yield menu.getItem('forof');
chai_1.expect(yield item.isDisplayed()).to.be.true;
chai_1.expect(yield item.getLabel()).equals('forof');
});
});
it('getItem - scroll', function () {
return __awaiter(this, void 0, void 0, function* () {
yield editor.setText('t');
const item = yield menu.getItem('throw');
chai_1.expect(yield item.isDisplayed()).to.be.true;
chai_1.expect(yield item.getLabel()).equals('throw');
});
});
it('getItems', function () {
return __awaiter(this, void 0, void 0, function* () {
const items = yield menu.getItems();
const titles = yield Promise.all(items.map((item) => item.getLabel()));
chai_1.expect(titles).not.to.be.empty;
});
});
it('isLoaded', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield menu.isLoaded()).to.be.true;
});
});
for (const item of validationItems) {
it(`hasItem("${item}")`, function () {
return __awaiter(this, void 0, void 0, function* () {
yield editor.setText(item[0]);
menu = (yield editor.toggleContentAssist(true));
yield menu.getItem(item);
chai_1.expect(yield menu.hasItem(item)).to.be.true;
});
});
}
it('select', function () {
return __awaiter(this, void 0, void 0, function* () {
yield editor.setText('c');
yield (menu === null || menu === void 0 ? void 0 : menu.select('class'));
const firstLine = yield editor.getTextAtLine(1);
try {
chai_1.expect(firstLine).contains('class name {');
}
catch (_a) {
chai_1.expect(firstLine).contains('class');
}
});
});
it('close', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield (menu === null || menu === void 0 ? void 0 : menu.isDisplayed())).to.be.true;
chai_1.expect(yield (menu === null || menu === void 0 ? void 0 : menu.isEnabled())).to.be.true;
yield (menu === null || menu === void 0 ? void 0 : menu.close());
try {
yield (menu === null || menu === void 0 ? void 0 : menu.isDisplayed());
chai_1.expect.fail('This code should not be reached.');
}
catch (_a) {
}
});
});
describe('ContentAssistItem', function () {
return __awaiter(this, void 0, void 0, function* () {
let item;
beforeEach(function () {
return __awaiter(this, void 0, void 0, function* () {
yield editor.setText('f');
item = (yield menu.getItem('forof'));
});
});
it('select', function () {
return __awaiter(this, void 0, void 0, function* () {
yield item.select();
const line = yield editor.getTextAtLine(1);
chai_1.expect(line).contains('for (const iterator of object)');
});
});
it('getParent', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(item.getParent()).equals(menu);
});
});
it('getLabel', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield item.getLabel()).equals('forof');
});
});
it('isNesting', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield item.isNesting()).to.be.false;
});
});
});
});
});
//# sourceMappingURL=ContentAssist.test.js.map