本文整理汇总了TypeScript中models/shared/version_updater.VersionUpdater类的典型用法代码示例。如果您正苦于以下问题:TypeScript VersionUpdater类的具体用法?TypeScript VersionUpdater怎么用?TypeScript VersionUpdater使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VersionUpdater类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: Date
jasmine.Ajax.withMock(() => {
jasmine.Ajax.stubRequest("/go/api/version_infos/stale", undefined, "GET").andReturn({
responseText: JSON.stringify({}),
status: 200
});
jasmine.Ajax.stubRequest("/go/api/version_infos/latest_version", undefined, "GET").andReturn({
responseText: JSON.stringify({}),
status: 200
});
const thirtyOneMinutesBack = new Date(Date.now() - 31 * 60 * 1000);
localStorage.setItem("versionCheckInfo", JSON.stringify({last_updated_at: thirtyOneMinutesBack}));
VersionUpdater.update();
const request = jasmine.Ajax.requests.at(0);
expect(request.method).toBe("GET");
expect(request.url).toBe("/go/api/version_infos/stale");
expect(request.requestHeaders["Content-Type"]).toContain("application/json");
expect(request.requestHeaders.Accept).toContain("application/vnd.go.cd.v1+json");
expect(JSON.parse(localStorage.getItem("system_notifications") as string)).toBeNull();
});
开发者ID:GaneshSPatil,项目名称:gocd,代码行数:26,代码来源:version_updater_spec.ts
示例2: spyOn
jasmine.Ajax.withMock(() => {
jasmine.Ajax.stubRequest("/go/api/version_infos/stale", undefined, "GET").andReturn({
responseText: JSON.stringify({update_server_url: "update.server.url"}),
responseHeaders: {
"Content-Type": `application/vnd.go.cd.v1+json`,
},
status: 200
});
jasmine.Ajax.stubRequest("update.server.url", undefined, "GET").andReturn({
responseText: JSON.stringify({foo: "bar"}),
responseHeaders: {
"Content-Type": "application/json"
},
status: 200
});
jasmine.Ajax.stubRequest("/go/api/version_infos/go_server", undefined, "PATCH").andReturn({
responseText: JSON.stringify({}),
responseHeaders: {
"Content-Type": `application/vnd.go.cd.v1+json`
},
status: 200
});
const myDate = jasmine.createSpyObj("Date", ["getTime"]);
// @ts-ignore
spyOn(window, "Date").and.returnValue(myDate);
myDate.getTime.and.callFake(() => 123);
VersionUpdater.update();
const request = jasmine.Ajax.requests.at(2);
expect(request.method).toBe("PATCH");
expect(request.url).toBe("/go/api/version_infos/go_server");
expect(JSON.parse(request.params)).toEqual({foo: "bar"});
expect(request.requestHeaders["Content-Type"]).toContain("application/json");
expect(request.requestHeaders.Accept).toContain("application/vnd.go.cd.v1+json");
expect(localStorage.getItem("versionCheckInfo")).toEqual("{\"last_updated_at\":123}");
});
开发者ID:GaneshSPatil,项目名称:gocd,代码行数:43,代码来源:version_updater_spec.ts
示例3: expect
jasmine.Ajax.withMock(() => {
jasmine.Ajax.stubRequest("/go/api/version_infos/stale", undefined, "GET").andReturn({
responseText: JSON.stringify({update_server_url: "update.server.url"}),
status: 200
});
jasmine.Ajax.stubRequest("update.server.url", undefined, "GET").andReturn({
responseText: JSON.stringify({}),
status: 200
});
VersionUpdater.update();
const request = jasmine.Ajax.requests.at(1);
expect(request.method).toBe("GET");
expect(request.url).toBe("update.server.url");
expect(request.requestHeaders.Accept).toContain("application/vnd.update.go.cd.v1+json");
});
开发者ID:GaneshSPatil,项目名称:gocd,代码行数:19,代码来源:version_updater_spec.ts
注:本文中的models/shared/version_updater.VersionUpdater类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论