本文整理匯總了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();
}
});