本文整理匯總了TypeScript中models/access_tokens/types.AccessToken類的典型用法代碼示例。如果您正苦於以下問題:TypeScript AccessToken類的具體用法?TypeScript AccessToken怎麽用?TypeScript AccessToken使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AccessToken類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("should deserialize token if provided", () => {
const newAccessTokenWithTokenText = AccessTokenTestData.newAccessTokenWithTokenText();
const accessToken = AccessToken.fromJSON(newAccessTokenWithTokenText);
expect(accessToken.description()).toEqual(newAccessTokenWithTokenText.description);
expect(accessToken.token()).toEqual(newAccessTokenWithTokenText.token as string);
});
示例2: it
it("should revoke access token", (done) => {
const accessToken = AccessToken.fromJSON(AccessTokenTestData.validAccessToken());
jasmine.Ajax.stubRequest(`${BASE_PATH}/${accessToken.id()}/revoke`).andReturn(revokedAccessTokenResponse());
const onResponse = jasmine.createSpy().and.callFake((response: ApiResult<any>) => {
const responseJSON = response.unwrap() as SuccessResponse<any>;
expect(responseJSON.body.object.description()).toEqual(accessToken.description());
expect(responseJSON.body.etag).toEqual("some-etag");
done();
});
AdminAccessTokenCRUD.revoke(accessToken, "Some cause to revoke the token").then(onResponse);
const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toEqual(`${BASE_PATH}/${accessToken.id()}/revoke`);
expect(request.method).toEqual("POST");
const data = toAccessTokenJSON(request.data());
expect(data.revoke_cause).toEqual("Some cause to revoke the token");
expect(request.requestHeaders.Accept).toEqual("application/vnd.go.cd.v1+json");
expect(request.requestHeaders["Content-Type"]).toEqual("application/json; charset=utf-8");
});