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


TypeScript Sinon.match類代碼示例

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


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

示例1: expect

 .catch(() => {
   expect(interceptor.response).not.to.have.callCount(1);
   expect(interceptor.responseError).to.have.been.calledWith(match.instanceOf(Response), match.instanceOf(Request), client);
   expect(fetch).to.have.callCount(4);
   expect(client.activeRequestCount).to.equal(0);
   expect(client.isRequesting).to.equal(false);
   done();
 });
開發者ID:aurelia,項目名稱:aurelia,代碼行數:8,代碼來源:http-client.spec.ts

示例2: 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

示例3: it

 it("renders a genetic track with a coloured label if so requested", () => {
     // given a genetic track specification with a label color
     const newProps: IOncoprintProps = {
         ...makeMinimalOncoprintProps(),
         geneticTracks: [{
             key: 'GENETICTRACK_14',
             label: 'GENE7',
             oql: 'GENE7: A316M;',
             info: '0%',
             data: [],
             labelColor: 'fuchsia'
         }]
     };
     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', 'fuchsia')]
         )
     );
 });
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:31,代碼來源:DeltaUtils.spec.ts

示例4: it

        it("should reject capability's Promise if reaction handler returns capability's Promise", () => {
            var reaction = reactionsHelpers.createFakeReaction(),
                capabilityRejectStub = sinon.stub(reaction.capability, "reject");

            reaction.handler = () => { return reaction.capability.promise; };
            abstract.PromiseReactionTask(reaction, null);

            sinon.assert.calledOnce(capabilityRejectStub);
            sinon.assert.calledWith(capabilityRejectStub, sinon.match.instanceOf(TypeError));
        });
開發者ID:spatools,項目名稱:promizr,代碼行數:10,代碼來源:abstract.ts

示例5: 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

示例6: it

 it("should call bindMiddleware (handler after global)", () => {
   this.bindMiddlewareStub.getCall(3).should.have.been.calledWithExactly(
     {target: "target after global"},
     {
       eventName: "eventName",
       args: ["arg1"],
       socket: "socket",
       nsp: "nsp"
     },
     Sinon.match.instanceOf(Promise)
   );
 });
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:12,代碼來源:SocketHandlersBuilder.spec.ts

示例7: 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


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