本文整理汇总了TypeScript中models/access_tokens/types.AccessToken.fromJSON方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AccessToken.fromJSON方法的具体用法?TypeScript AccessToken.fromJSON怎么用?TypeScript AccessToken.fromJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models/access_tokens/types.AccessToken
的用法示例。
在下文中一共展示了AccessToken.fromJSON方法的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");
});