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


TypeScript match.has方法代码示例

本文整理汇总了TypeScript中Sinon.match.has方法的典型用法代码示例。如果您正苦于以下问题:TypeScript match.has方法的具体用法?TypeScript match.has怎么用?TypeScript match.has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sinon.match的用法示例。


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

示例1: it

    it("should configure request and create context logger (no debug, logRequest)", () => {
      // GIVEN
      const injector = new InjectorService();
      injector.settings.logger = {debug: false, logRequest: true};
      injector.logger = {
        info: Sinon.stub(),
        warn: Sinon.stub(),
        debug: Sinon.stub(),
        trace: Sinon.stub(),
        error: Sinon.stub()
      };

      const middleware = new LogIncomingRequestMiddleware(injector);

      const request = new FakeRequest();
      request.method = "GET";
      request.url = "url";
      request.originalUrl = "originalUrl";
      request.ctx.data = "test";

      const response = new FakeResponse();
      response.statusCode = 200;
      // WHEN
      middleware.use(request as any);

      // THEN
      request.log.should.instanceof(RequestLogger);
      request.log.id.should.deep.equal(request.ctx.id);

      // THEN
      middleware.$onResponse(request as any, response as any);

      // THEN
      injector.logger.info.should.have.been.calledWithExactly(Sinon.match({
        event: "request.start",
        method: "GET",
        reqId: "id",
        url: "originalUrl"
      }));
      injector.logger.info.should.have.been.calledWithExactly(Sinon.match({
        event: "request.end",
        method: "GET",
        reqId: "id",
        url: "originalUrl",
        status: 200
      }));
      injector.logger.info.should.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number));
      injector.logger.info.should.have.been.calledWithExactly(Sinon.match.has("time", Sinon.match.instanceOf(Date)));
    });
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:49,代码来源:LogIncomingRequestMiddleware.spec.ts

示例2: it

 it("renders a heatmap track with a coloured label if so requested", () => {
     // given a single-gene heatmap track specification with a label color
     const newProps: IOncoprintProps = {
         ...makeMinimalOncoprintProps(),
         heatmapTracks: [{
             key: '"HEATMAPTRACK_mystudy_Zscores,GENE25"',
             label: '  GENE25',
             data: [],
             molecularProfileId: 'mystudy_Zscores',
             molecularAlterationType: 'MRNA_EXPRESSION',
             datatype: 'Z-SCORE',
             onRemove: () => { /* update external state */ },
             trackGroupIndex: 3,
             labelColor: 'olive'
         }]
     };
     const oncoprint: OncoprintJS<any> = createStubInstance(OncoprintJS);
     (oncoprint.addTracks as SinonStub).returns([1]);
     const trackIdsByKey = {};
     // when instructed to render the track from scratch
     transition(
         newProps,
         makeMinimalOncoprintProps(),
         oncoprint,
         () => trackIdsByKey,
         () => makeMinimalProfileMap()
     );
     // then it adds a track with the specified track label color
     assert.isTrue(
         (oncoprint.addTracks as SinonStub).calledWith(
             [match.has('track_label_color', 'olive')]
         )
     );
 });
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:34,代码来源:DeltaUtils.spec.ts

示例3: it

  it('process a hover request', async () => {
    const lspservice = mockLspService();
    try {
      const workspaceHandler = lspservice.workspaceHandler;
      const wsSpy = sinon.spy(workspaceHandler, 'handleRequest');
      const controller = lspservice.controller;
      const ctrlSpy = sinon.spy(controller, 'handleRequest');

      const revision = 'master';

      const response = await sendHoverRequest(lspservice, revision);
      assert.ok(response);
      assert.ok(response.result.contents);

      wsSpy.restore();
      ctrlSpy.restore();

      const workspaceFolderExists = fs.existsSync(
        path.join(serverOptions.workspacePath, repoUri, revision)
      );
      // workspace is opened
      assert.ok(workspaceFolderExists);

      const workspacePath = fs.realpathSync(
        path.resolve(serverOptions.workspacePath, repoUri, revision)
      );
      // workspace handler is working, filled workspacePath
      sinon.assert.calledWith(
        ctrlSpy,
        sinon.match.has('workspacePath', sinon.match(value => comparePath(value, workspacePath)))
      );
      // uri is changed by workspace handler
      sinon.assert.calledWith(
        ctrlSpy,
        sinon.match.hasNested('params.textDocument.uri', `file://${workspacePath}/${filename}`)
      );
      return;
    } finally {
      await lspservice.shutdown();
    }
    // @ts-ignore
  }).timeout(10000);
开发者ID:elastic,项目名称:kibana,代码行数:42,代码来源:lsp_service.ts

示例4: it

        it('should handle error adding identity to wallet', fakeAsync(() => {
            mockGetConnectionProfile.returns({
                type: 'web'
            });

            mockModal.open.returns({
                result: Promise.resolve({userID: 'myId', userSecret: 'mySecret'})
            });

            mockAddIdentityToWallet.rejects(new Error('add identity to wallet error'));

            mockAlertService.errorStatus$.next.should.not.have.been.called;

            component.issueNewId();

            tick();

            mockModal.open.should.have.been.calledOnce;

            let expectedError = sinon.match(sinon.match.instanceOf(Error).and(sinon.match.has('message', 'add identity to wallet error')));
            mockAlertService.errorStatus$.next.should.have.been.calledWith(expectedError);

            mockLoadAllIdentities.should.have.been.called;
        }));
开发者ID:bloonbullet,项目名称:composer,代码行数:24,代码来源:identity.component.spec.ts

示例5: it

 it('should call filter impl with correct this arg', async function () {
   const spy = sinon.spy()
   Filter.register('foo', spy)
   await new Filter('foo', ['33'], false).render('foo', ctx)
   expect(spy).to.have.been.calledOn(sinon.match.has('context', ctx))
 })
开发者ID:harttle,项目名称:shopify-liquid,代码行数:6,代码来源:filter.ts

示例6: expect

 return userService.createUser(user).then(result => {
   expect(result.id).to.equal(1);
   expect(result.role).to.equal('user');
   expect(stub.calledWith(sinon.match.has('provider', 'local'))).to.equal(true);
   expect(stub.calledWith(sinon.match.has('role', 'user'))).to.equal(true);
 })
开发者ID:steelheaddigital,项目名称:angular2-express-starter,代码行数:6,代码来源:user_service.spec.ts


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