當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript typeahead-popup.TypeaheadPopup類代碼示例

本文整理匯總了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);
    });
  });
});
開發者ID:lddubeau,項目名稱:wed,代碼行數:74,代碼來源:typeahead-popup-test.ts

示例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");
    });
開發者ID:lddubeau,項目名稱:wed,代碼行數:8,代碼來源:typeahead-popup-test.ts

示例3: afterEach

 afterEach(() => {
   if (ta !== undefined) {
     ta.dismiss();
   }
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:5,代碼來源:typeahead-popup-test.ts


注:本文中的wed/gui/typeahead-popup.TypeaheadPopup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。