本文整理汇总了TypeScript中models/users/users_crud.UsersCRUD类的典型用法代码示例。如果您正苦于以下问题:TypeScript UsersCRUD类的具体用法?TypeScript UsersCRUD怎么用?TypeScript UsersCRUD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UsersCRUD类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should make a patch request", (done) => {
const bulkUpdateUserJSON = {
users: ["bob", "alice"],
operations: {
enable: true
}
};
jasmine.Ajax.stubRequest(BULK_UPDATE_USERS_API, JSON.stringify(bulkUpdateUserJSON), "PATCH").andReturn({
status: 200,
responseHeaders: {
"Content-Type": "application/vnd.go.cd.v3+json; charset=utf-8",
"ETag": "some-etag"
},
responseText: JSON.stringify(
bulkUpdateUserJSON)
});
const onResponse = jasmine.createSpy().and.callFake((response: ApiResult<any>) => {
done();
} );
UsersCRUD.bulkUserStateUpdate(bulkUpdateUserJSON).then(onResponse);
const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toEqual(BULK_UPDATE_USERS_API);
expect(request.method).toEqual("PATCH");
expect(request.requestHeaders)
.toEqual({"Accept": "application/vnd.go.cd.v3+json", "Content-Type": "application/json; charset=utf-8"});
});
示例2: it
it("should make a get request", (done) => {
const userJSON = users()[0];
const GET_USER_API = "/go/api/users/bob";
jasmine.Ajax.stubRequest(GET_USER_API).andReturn({
status: 200,
responseHeaders: {
"Content-Type": "application/vnd.go.cd.v3+json; charset=utf-8",
"ETag": "some-etag"
},
responseText: JSON.stringify(
userJSON)
});
const onResponse = jasmine.createSpy().and.callFake((response: ApiResult<User>) => {
const responseJSON = response.unwrap() as SuccessResponse<User>;
expect(responseJSON.body.loginName()).toEqual(userJSON.login_name);
done();
});
UsersCRUD.get("bob").then(onResponse);
const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toEqual(GET_USER_API);
expect(request.method).toEqual("GET");
expect(request.requestHeaders.Accept).toEqual("application/vnd.go.cd.v3+json");
});