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


TypeScript service.ScrollSpyService.spyOn方法代碼示例

本文整理匯總了TypeScript中app/shared/scroll-spy.service.ScrollSpyService.spyOn方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.ScrollSpyService.spyOn方法的具體用法?TypeScript service.ScrollSpyService.spyOn怎麽用?TypeScript service.ScrollSpyService.spyOn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app/shared/scroll-spy.service.ScrollSpyService的用法示例。


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

示例1: it

    it('should forward `ScrollSpiedElementGroup#activeScrollItem` as `active`', () => {
      const activeIndices1: (number | null)[] = [];
      const activeIndices2: (number | null)[] = [];

      const info1 = scrollSpyService.spyOn([]);
      const info2 = scrollSpyService.spyOn([]);
      const spiedElemGroups = getSpiedElemGroups();

      info1.active.subscribe(item => activeIndices1.push(item && item.index));
      info2.active.subscribe(item => activeIndices2.push(item && item.index));
      activeIndices1.length = 0;
      activeIndices2.length = 0;

      spiedElemGroups[0].activeScrollItem.next({index: 1} as ScrollItem);
      spiedElemGroups[0].activeScrollItem.next({index: 2} as ScrollItem);
      spiedElemGroups[1].activeScrollItem.next({index: 3} as ScrollItem);
      spiedElemGroups[0].activeScrollItem.next(null);
      spiedElemGroups[1].activeScrollItem.next({index: 4} as ScrollItem);
      spiedElemGroups[1].activeScrollItem.next(null);
      spiedElemGroups[0].activeScrollItem.next({index: 5} as ScrollItem);
      spiedElemGroups[1].activeScrollItem.next({index: 6} as ScrollItem);

      expect(activeIndices1).toEqual([1, 2, null, 5]);
      expect(activeIndices2).toEqual([3, 4, null, 6]);
    });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:25,代碼來源:scroll-spy.service.spec.ts

示例2: it

    it('should call `onResize()` if it is the first `ScrollSpiedElementGroup`', () => {
      const actions: string[] = [];

      const onResizeSpy = spyOn(ScrollSpyService.prototype as any, 'onResize')
                          .and.callFake(() => actions.push('onResize'));
      const calibrateSpy = spyOn(ScrollSpiedElementGroup.prototype, 'calibrate')
                           .and.callFake(() => actions.push('calibrate'));

      expect(onResizeSpy).not.toHaveBeenCalled();

      scrollSpyService.spyOn([]);
      expect(actions).toEqual(['onResize', 'calibrate']);

      scrollSpyService.spyOn([]);
      expect(actions).toEqual(['onResize', 'calibrate', 'calibrate']);
    });
開發者ID:DanielKucal,項目名稱:angular,代碼行數:16,代碼來源:scroll-spy.service.spec.ts

示例3: it

    it('should only fire every 300ms', fakeAsync(() => {
      scrollSpyService.spyOn([]);

      window.dispatchEvent(new Event('scroll'));
      tick(100);
      expect(onScrollSpy).not.toHaveBeenCalled();

      window.dispatchEvent(new Event('scroll'));
      tick(100);
      expect(onScrollSpy).not.toHaveBeenCalled();

      window.dispatchEvent(new Event('scroll'));
      tick(100);
      expect(onScrollSpy).toHaveBeenCalledTimes(1);

      onScrollSpy.calls.reset();
      tick(150);

      window.dispatchEvent(new Event('scroll'));
      tick(100);
      expect(onScrollSpy).not.toHaveBeenCalled();

      window.dispatchEvent(new Event('scroll'));
      tick(100);
      expect(onScrollSpy).not.toHaveBeenCalled();

      window.dispatchEvent(new Event('scroll'));
      tick(100);
      expect(onScrollSpy).toHaveBeenCalledTimes(1);
    }));
開發者ID:rjamet,項目名稱:angular,代碼行數:30,代碼來源:scroll-spy.service.spec.ts


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