當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript VersionUpdater.update方法代碼示例

本文整理匯總了TypeScript中models/shared/version_updater.VersionUpdater.update方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript VersionUpdater.update方法的具體用法?TypeScript VersionUpdater.update怎麽用?TypeScript VersionUpdater.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models/shared/version_updater.VersionUpdater的用法示例。


在下文中一共展示了VersionUpdater.update方法的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.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。