当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chai.spy函数代码示例

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


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

示例1: it

        it('should match and call function', async () => {
            let inc = 1;
            function getMatchRoot(req: ServerRequest, res: ServerResponse) {}
            function getMatchRootId(req: ServerRequest, res: ServerResponse, id: string) {
                assert.isTrue(id === inc.toString());
                ++inc;
            }

            let spyFunctionRoot = spy(getMatchRoot);
            let spyFunctionRootId = spy(getMatchRootId);

            helloRoute.get('/spy', spyFunctionRoot);
            helloRoute.get('/spy/:id', spyFunctionRootId);
            helloRoute.get('/spy/:id/hello', spyFunctionRootId);
            helloRoute.get('/spy/:id/hello/world', spyFunctionRootId);

            assert.isTrue(
                await helloRoute.parse({ url: '/spy' }, new MockReq({ method: 'GET' }), null)
            );

            assert.isTrue(
                await helloRoute.parse({ url: '/spy/1' }, new MockReq({ method: 'GET' }), null)
            );
            assert.isTrue(
                await helloRoute.parse({ url: '/spy/2' }, new MockReq({ method: 'GET' }), null)
            );

            expect(spyFunctionRoot).to.have.been.called.exactly(1);
            expect(spyFunctionRootId).to.have.been.called.exactly(2);
        });
开发者ID:fosenutvikling,项目名称:fuhttp-ts,代码行数:30,代码来源:Route.test.ts

示例2: it

 it('should not re-pause if countdown was already paused', () => {
   const spyClearInterval = chai.spy(clearInterval);
   countdown.pauseCountdown();
   clock.tick(5000);
   countdown.pauseCountdown();
   expect(spyClearInterval).to.not.have.been.called;
 });
开发者ID:joelalejandro,项目名称:xethya,代码行数:7,代码来源:countdown.test.ts

示例3: it

    it('should correctly notice array size changes', function (done) {
        var dummyModel = {
            foo: 10,
            bar: [ 10, 20 ]
        };

        var rulesetBuilder = new RulesetBuilder();
        var ruleset = rulesetBuilder.create()
            .forProperty("foo")
            .addRule("required", true)
            .forProperty("bar")
            .addRule("minLength", 1)
            .addRuleForEach("maxValue", 20)
            .build();

        var modelWatcher = new ModelWatcher();
        modelWatcher.setupWatcher(dummyModel, ruleset, 50);
        var spySubscription = spy(function(eventArgs){});

        modelWatcher.onPropertyChanged.subscribe(spySubscription);

        dummyModel.bar.push(30);

        setTimeout(function(){
            expect(spySubscription).to.have.been.called.exactly(2);
            modelWatcher.stopWatching();
            done();
        }, 250);
    });
开发者ID:jsobell,项目名称:treacherous,代码行数:29,代码来源:model-watcher-tests.ts

示例4: it

  it('should call find of model', () => {
    const spy = chai.spy();
    const model = {
      find: spy
    };

    findAll(model);

    expect(spy).to.have.been.called();
  });
开发者ID:Cyphle,项目名称:Portfolio,代码行数:10,代码来源:mongodb.repository.spec.ts


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