当前位置: 首页>>代码示例>>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;未经允许,请勿转载。