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


TypeScript testing.createKeyboardEvent函數代碼示例

本文整理匯總了TypeScript中@angular/cdk/testing.createKeyboardEvent函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createKeyboardEvent函數的具體用法?TypeScript createKeyboardEvent怎麽用?TypeScript createKeyboardEvent使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createKeyboardEvent函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should check whether the alt key is pressed', () => {
    const event = createKeyboardEvent('keydown', 0);

    expect(hasModifierKey(event)).toBe(false);
    Object.defineProperty(event, 'altKey', {get: () => true});
    expect(hasModifierKey(event)).toBe(true);
  });
開發者ID:Nodarii,項目名稱:material2,代碼行數:7,代碼來源:modifiers.spec.ts

示例2: createKeyboardEvent

    [ENTER, SPACE].forEach(key => {
      const event = createKeyboardEvent('keydown', key);
      Object.defineProperty(event, 'shiftKey', {get: () => true});
      dispatchEvent(optionNativeElement, event);
      fixture.detectChanges();

      expect(event.defaultPrevented).toBe(false);
    });
開發者ID:Nodarii,項目名稱:material2,代碼行數:8,代碼來源:option.spec.ts

示例3: it

    it('should be able to use keyboard select with SPACE', () => {
      let testListItem = listOption[1].nativeElement as HTMLElement;
      let SPACE_EVENT: KeyboardEvent =
        createKeyboardEvent('keydown', SPACE, testListItem);
      let selectList = selectionList.injector.get<MdSelectionList>(MdSelectionList).selectedOptions;
      let options = selectionList.componentInstance.options;
      let array = options.toArray();
      let focusItem = array[1];
      expect(selectList.selected.length).toBe(0);

      focusItem.focus();
      selectionList.componentInstance._keydown(SPACE_EVENT);

      fixture.detectChanges();

      expect(selectList.selected.length).toBe(1);
    });
開發者ID:eromano,項目名稱:material2,代碼行數:17,代碼來源:selection-list.spec.ts


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