本文整理汇总了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();
});
示例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}");
});
示例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");
});