本文整理汇总了TypeScript中Sinon.assert.calledWithExactly方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.calledWithExactly方法的具体用法?TypeScript assert.calledWithExactly怎么用?TypeScript assert.calledWithExactly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.assert
的用法示例。
在下文中一共展示了assert.calledWithExactly方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('redirects to the home page if new SAML Response is for the same user.', async () => {
const request = requestFixture({ payload: { SAMLResponse: 'saml-response-xml' } });
const user = { username: 'user', authentication_realm: { name: 'saml1' } };
callWithRequest.withArgs(request, 'shield.authenticate').resolves(user);
callWithInternalUser
.withArgs('shield.samlAuthenticate')
.resolves({ access_token: 'new-valid-token', refresh_token: 'new-valid-refresh-token' });
const deleteAccessTokenStub = callWithInternalUser
.withArgs('shield.deleteAccessToken')
.resolves({ invalidated_tokens: 1 });
const authenticationResult = await provider.authenticate(request, {
accessToken: 'existing-valid-token',
refreshToken: 'existing-valid-refresh-token',
});
sinon.assert.calledWithExactly(callWithInternalUser, 'shield.samlAuthenticate', {
body: { ids: [], content: 'saml-response-xml' },
});
sinon.assert.calledTwice(deleteAccessTokenStub);
sinon.assert.calledWithExactly(deleteAccessTokenStub, 'shield.deleteAccessToken', {
body: { token: 'existing-valid-token' },
});
sinon.assert.calledWithExactly(deleteAccessTokenStub, 'shield.deleteAccessToken', {
body: { refresh_token: 'existing-valid-refresh-token' },
});
expect(authenticationResult.redirected()).toBe(true);
expect(authenticationResult.redirectURL).toBe('/test-base-path/');
});
示例2: it
it('redirects to /login with optional search parameters if tokens are deleted successfully', async () => {
const request = requestFixture({ search: '?yep' });
const accessToken = 'foo';
const refreshToken = 'bar';
callWithInternalUser
.withArgs('shield.deleteAccessToken', { body: { token: accessToken } })
.returns({ created: true });
callWithInternalUser
.withArgs('shield.deleteAccessToken', { body: { refresh_token: refreshToken } })
.returns({ created: true });
const authenticationResult = await provider.deauthenticate(request, {
accessToken,
refreshToken,
});
sinon.assert.calledTwice(callWithInternalUser);
sinon.assert.calledWithExactly(callWithInternalUser, 'shield.deleteAccessToken', {
body: { token: accessToken },
});
sinon.assert.calledWithExactly(callWithInternalUser, 'shield.deleteAccessToken', {
body: { refresh_token: refreshToken },
});
expect(authenticationResult.redirected()).toBe(true);
expect(authenticationResult.redirectURL).toBe('/base-path/login?yep');
});
示例3:
promizr.findSeries(list, iterator).then(e => {
sinon.assert.calledOnce(spy);
sinon.assert.calledWithExactly(spy, list[0]);
sinon.assert.calledOnce(iterator);
sinon.assert.calledWithExactly(iterator, list[0], 0, list);
}).then(done, done);
示例4:
.then(() => {
stubActionUserUpsert.restore();
response.redirect;
Sinon.assert.calledOnce(stubActionUserUpsert);
Sinon.assert.calledWithExactly(stubActionUserUpsert, googleUser);
request.session.user.should.be.equals(mongoUser);
request.session.access_token.should.be.equals(token);
Chai.assert.isUndefined(application.accessTokens[userId]);
Sinon.assert.calledOnce(response.redirect);
Sinon.assert.calledWithExactly(response.redirect, "/");
});
示例5: it
it('should allow reusing drivers for many apps', function(done) {
const sandbox = sinon.createSandbox();
const spy1 = sandbox.spy();
const spy2 = sandbox.spy();
type NiceSources = {
other: Stream<string>;
};
type NiceSinks = {
other: Stream<string>;
};
function app1(sources: NiceSources): NiceSinks {
return {
other: sources.other.mapTo('a').debug(spy1),
};
}
function app2(sources: NiceSources): NiceSinks {
return {
other: sources.other.mapTo('x').debug(spy2),
};
}
let sinkCompleted = 0;
function driver(sink: Stream<string>) {
sink.addListener({
complete: () => {
sinkCompleted++;
done(
new Error('complete should not be called before engine is before')
);
},
});
return xs.of('b');
}
const engine = setupReusable({other: driver});
const dispose1 = engine.run(app1(engine.sources));
sinon.assert.calledOnce(spy1);
sinon.assert.calledWithExactly(spy1, 'a');
sandbox.restore();
dispose1();
const dispose2 = engine.run(app2(engine.sources));
sinon.assert.calledOnce(spy2);
sinon.assert.calledWithExactly(spy2, 'x');
dispose2();
assert.strictEqual(sinkCompleted, 0);
done();
});
示例6: it
it("check main flow", () => {
const application = new App.Application();
const request: any = {
logout: Sinon.stub(),
session: {
access_token: "Access Token",
destroy: Sinon.stub().callsFake((callback: () => any) => callback()),
},
};
const response = {
redirect: Sinon.stub(),
};
const stubHttpsGet = Sinon.stub(Https, "get").callsFake((params, callback) => {
params.should.be.deep.equals({
host: "accounts.google.com",
method: "GET",
path: "/o/oauth2/logout?token=" + request.session.access_token,
protocol: "https:",
});
callback(null);
});
application.passportLogout(request, response);
stubHttpsGet.restore();
Sinon.assert.calledOnce(request.session.destroy);
Sinon.assert.calledOnce(request.logout);
Sinon.assert.calledOnce(response.redirect);
Sinon.assert.calledWithExactly(response.redirect, "/");
});