本文整理汇总了TypeScript中Sinon.match.instanceOf方法的典型用法代码示例。如果您正苦于以下问题:TypeScript match.instanceOf方法的具体用法?TypeScript match.instanceOf怎么用?TypeScript match.instanceOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.match
的用法示例。
在下文中一共展示了match.instanceOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
});
示例2: 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));
});
示例3: 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)
);
});
示例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;
}));
示例5: it
it('should initialize with config data', fakeAsync(inject([InitializationService], (service: InitializationService) => {
mockConfigService.loadConfig.returns(Promise.resolve(mockConfig));
mockIdentityCardService.loadIdentityCards.returns(Promise.resolve());
mockIdentityCardService.addInitialIdentityCards.returns(Promise.resolve(['cardRef']));
service.initialize();
tick();
mockConfigService.loadConfig.should.be.called;
mockIdentityCardService.loadIdentityCards.should.have.been.called;
mockIdentityCardService.addInitialIdentityCards.should.have.been.calledWith([sinon.match.instanceOf(IdCard)]);
})));
示例6: 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)));
});