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