本文整理汇总了TypeScript中wed/gui/typeahead-popup.TypeaheadPopup类的典型用法代码示例。如果您正苦于以下问题:TypeScript TypeaheadPopup类的具体用法?TypeScript TypeaheadPopup怎么用?TypeScript TypeaheadPopup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeaheadPopup类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe("TypeaheadPopup", () => {
let ta: TypeaheadPopup;
let cb: sinon.SinonSpy;
beforeEach(() => {
cb = sinon.spy();
ta = new TypeaheadPopup(
window.document, 0, 0, 300, "Placeholder",
{
options: {
autoselect: true,
hint: true,
highlight: true,
minLength: 1,
},
datasets: [{
source: substringMatcher(testData),
}],
},
cb,
);
});
afterEach(() => {
if (ta !== undefined) {
ta.dismiss();
}
});
describe("setValue", () => {
it("sets the value", () => {
const ttInput =
document.getElementsByClassName("tt-input")[0] as HTMLInputElement;
assert.notEqual(ttInput.value, "foo");
ta.setValue("foo");
assert.equal(ttInput.value, "foo");
});
});
describe("hideSpinner", () => {
it("hides the spinner", () => {
const spinner =
document.querySelector(".wed-typeahead-popup .spinner") as HTMLElement;
assert.notEqual(spinner.style.display, "none");
ta.hideSpinner();
assert.equal(spinner.style.display, "none");
});
});
describe("dismiss", () => {
it("calls the callback without a value if no value is given", () => {
ta.dismiss();
assert.isTrue(cb.calledWith(undefined));
});
it("calls the callback with the value passed", () => {
ta.dismiss(testData[0]);
assert.isTrue(cb.calledWith(testData[0]));
});
it("calls the callback with the value passed", () => {
ta.dismiss(testData[0]);
assert.isTrue(cb.calledWith(testData[0]));
});
it("calls the callback only once", () => {
ta.dismiss();
ta.dismiss();
assert.isTrue(cb.calledOnce);
});
});
});
示例2: it
it("hides the spinner", () => {
const spinner =
document.querySelector(".wed-typeahead-popup .spinner") as HTMLElement;
assert.notEqual(spinner.style.display, "none");
ta.hideSpinner();
assert.equal(spinner.style.display, "none");
});
示例3: afterEach
afterEach(() => {
if (ta !== undefined) {
ta.dismiss();
}
});