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


TypeScript assert.is函數代碼示例

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


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

示例1: it

  it('Should set default image for img and all picture source elements', () => {
    // Arrange
    const imagePath1 = 'https://some-path/image1.jpg';
    const imagePath2 = 'https://some-path/image2.jpg';
    const imagePath3 = 'https://some-path/image3.jpg';
    const picture = document.createElement('picture');
    const source1 = document.createElement('source');
    const source2 = document.createElement('source');
    const img = document.createElement('img');
    source1.setAttribute('defaultImage', imagePath2);
    source2.setAttribute('defaultImage', imagePath3);
    picture.appendChild(source1);
    picture.appendChild(source2);
    picture.appendChild(img);

    const attribute = {
      element: img,
      defaultImagePath: imagePath1,
      useSrcset: false
    };

    // Act
    sharedPreset.setup(attribute as any);

    // Assert
    is(img.src, imagePath1);
    is(source1.srcset, imagePath2);
    is(source2.srcset, imagePath3);
  });
開發者ID:tjoskar,項目名稱:ng2-lazyload-image,代碼行數:29,代碼來源:preset.test.ts

示例2: getScrollListener

 const subscriber = getScrollListener(element).subscribe(d => {
   events.push(d);
   if (events.length === 2) {
     is(events[0], '');
     is(events[1], 'oskar');
     subscriber.unsubscribe();
     done();
   }
 });
開發者ID:tjoskar,項目名稱:ng2-lazyload-image,代碼行數:9,代碼來源:scroll-listener.test.ts

示例3: it

    it("Should return an empty Rect if two Rect's don't intersect", () => {
      // Arrange
      const rectA = new Rect(0, 0, 20, 20);
      const rectB = new Rect(30, 30, 50, 50);

      // Act
      const result = rectA.getIntersectionWith(rectB);

      // Assert
      is(result.top, 0);
      is(result.right, 0);
      is(result.bottom, 0);
      is(result.left, 0);
    });
開發者ID:tjoskar,項目名稱:ng2-lazyload-image,代碼行數:14,代碼來源:rect.test.ts

示例4: it

  it('Should call removeEventListener on unsubscribe', () => {
    // Arrange
    let argumants = {
      eventName: '',
      handler: null,
      options: null
    };
    const element = {
      addEventListener(eventName, handler, options) {
        argumants = { eventName, handler, options };
      },
      removeEventListener: spy((eventName, handler, options) => {
        is(argumants.eventName, eventName);
        is(argumants.options.passive, options.passive);
        is(argumants.options.capture, options.capture);
        is(argumants.handler, handler);
      })
    };

    // Act
    const subscription = getScrollListener(element).subscribe();
    subscription.unsubscribe();

    // Assert
    is(
      element.removeEventListener.callCount,
      1,
      'Should call removeEventListener one time'
    );
  });
開發者ID:tjoskar,項目名稱:ng2-lazyload-image,代碼行數:30,代碼來源:scroll-listener.test.ts

示例5: it

  it("Should not be visible when image's rect is empty and has an offset", () => {
    const attribute = {
      event: undefined,
      element: generateElement(0, 0, 0, 0),
      offset: 100
    };
    const result = isVisible(attribute, getWindow);

    is(result, false);
  });
開發者ID:tjoskar,項目名稱:ng2-lazyload-image,代碼行數:10,代碼來源:preset.test.ts


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