• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript chai.spy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中chai.spy的典型用法代码示例。如果您正苦于以下问题:TypeScript spy类的具体用法?TypeScript spy怎么用?TypeScript spy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了spy类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

        it("should not propagate if stopPropagation is passed", () => {
            const spy = chai.spy.on(parent, "updateValidity");

            parent.child.setIssue({
                [parent.child.loc]: {
                    message: "",
                    type: "error",
                    code: ErrorCode.ID_INVALID_CHAR
                }
            }, true);

            expect(spy).to.not.have.been.called;
            expect(parent.errors).to.be.empty;
            expect(parent.child.errors).to.have.lengthOf(1);
        });
开发者ID:mayacoda,项目名称:cwl-ts,代码行数:15,代码来源:ValidationBase.spec.ts


示例2: it

    it('should clear everything using #remove', () => {
      const spyRemove = chai.spy.on(collection, 'remove');
      collection.removeAll();

      const eventListeners: string[] = collection.eventNames() as string[]

      expect(eventListeners.filter(
        (eventName: string) => /foo/.test(eventName)
      )).to.be.empty;

      expect(eventListeners.filter(
        (eventName: string) => /bar/.test(eventName)
      )).to.be.empty;

      expect(spyRemove).to.have.been.called.twice;
      expect(collection.count).to.equal(0);
    });
开发者ID:joelalejandro,项目名称:xethya,代码行数:17,代码来源:stat-collection.test.ts


示例3: it

    it('Should not delete the todo from the interactor nor set the collection if the gateway rejected the Promise', done => {
      const spy = chai.spy.on(controller, 'setTodoCollection')

      gateway.removeTodo = id => Promise.reject('Spec rejected the Promise intentionnaly')

      sut.deleteTodo(todo.id)
        .catch(() => {
          expect(sut.todos).to.deep.equal([
            todo,
            todo_
          ])

          expect(spy).not.to.have.been.called

          done()
        })
    })
开发者ID:Evgeniia0511,项目名称:clean-todo,代码行数:17,代码来源:todo.interactor.spec.ts


示例4: it

  it('should call challengeResolver when checking for challenge', () => {
    const spy = chai.spy.on(combat, 'challengeResolver');

    expect(combat.challenge()).to.be.true;
    expect(spy).to.have.been.called;
  });
开发者ID:joelalejandro,项目名称:xethya,代码行数:6,代码来源:combat-simulation.test.ts


示例5: afterEach

 afterEach(() => spy.restore(console));
开发者ID:vladjerca,项目名称:imgstry,代码行数:1,代码来源:logger.test.ts


示例6: on

    on(name: string, fn: () => void) {
    }
};

let spiedFn = chai.spy(original);

// then use in place of original
ee.on('some event', spiedFn);

// or use without original
let spy_again = chai.spy();
ee.on('some other event', spy_again);

// or you can track an object's method
let array = [ 1, 2, 3 ];
chai.spy.on(array, 'push');

// or you can track multiple object's methods
chai.spy.on(array, 'push', 'pop');

array.push(5);

// and you can reset the object calls
// array.push.reset();

// or you can create spy object
let object = chai.spy.object([ 'push', 'pop' ]);
object.push(5);

// or you create spy which returns static value
spiedFn = chai.spy.returns(true);
开发者ID:CaselIT,项目名称:DefinitelyTyped,代码行数:31,代码来源:chai-spies-tests.ts


示例7: on

    on(name: string, fn: () => void) {
    }
};

let spiedFn = chai.spy(original);

// then use in place of original
ee.on('some event', spiedFn);

// or use without original
let spy_again = chai.spy();
ee.on('some other event', spy_again);

// or you can track an object's method
let array = [ 1, 2, 3 ];
chai.spy.on(array, 'push');

// or you can track multiple object's methods
chai.spy.on(array, ['push', 'pop']);

// or you can track multiple object's methods
chai.spy.on(array, 'push', function(item) {
    array.push(item);
});

array.push(5);

// and you can reset the object calls
// array.push.reset();

// or you can create spy object
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:chai-spies-tests.ts


示例8: it

 it('should do nothing if setting value without changes', () => {
   const modifier = new Modifier('foo', 10);
   const spyEmit = chai.spy.on(modifier, 'emit');
   modifier.value = 10;
   expect(spyEmit).to.not.have.been.called;
 });
开发者ID:joelalejandro,项目名称:xethya,代码行数:6,代码来源:modifier.test.ts



注:本文中的chai.spy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript chakram.expect函数代码示例发布时间:2022-05-25
下一篇:
TypeScript chai.request类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap