From 05fb0d4ad96a40c186b32ffc2082ece25937c123 Mon Sep 17 00:00:00 2001 From: Djordje Date: Mon, 2 Dec 2024 10:21:30 +0100 Subject: [PATCH] Reformat code --- src/test/acquisition-rest-mock.ts | 8 ++++---- src/test/acquisition-sdk.ts | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/acquisition-rest-mock.ts b/src/test/acquisition-rest-mock.ts index b162e003..b3620d83 100644 --- a/src/test/acquisition-rest-mock.ts +++ b/src/test/acquisition-rest-mock.ts @@ -28,13 +28,13 @@ export function updateMockUrl() { updateCheckUrl = serverUrl + publicPrefixUrl + "/update_check?"; } - export class HttpRequester implements acquisitionSdk.Http.Requester { private expectedStatusCode: number; constructor(expectedStatusCode?: number) { this.expectedStatusCode = expectedStatusCode; } + public request(verb: acquisitionSdk.Http.Verb, url: string, requestBodyOrCallback: string | acquisitionSdk.Callback, callback?: acquisitionSdk.Callback): void { if (!callback && typeof requestBodyOrCallback === "function") { callback = >requestBodyOrCallback; @@ -42,11 +42,11 @@ export class HttpRequester implements acquisitionSdk.Http.Requester { if (verb === acquisitionSdk.Http.Verb.GET && url.indexOf(updateCheckUrl) === 0) { var params = querystring.parse(url.substring(updateCheckUrl.length)); - Server.onUpdateCheck(params, callback,this.expectedStatusCode); + Server.onUpdateCheck(params, callback, this.expectedStatusCode); } else if (verb === acquisitionSdk.Http.Verb.POST && url === reportStatusDeployUrl) { - Server.onReportStatus(callback,this.expectedStatusCode); + Server.onReportStatus(callback, this.expectedStatusCode); } else if (verb === acquisitionSdk.Http.Verb.POST && url === reportStatusDownloadUrl) { - Server.onReportStatus(callback,this.expectedStatusCode); + Server.onReportStatus(callback, this.expectedStatusCode); } else { throw new Error("Unexpected call"); } diff --git a/src/test/acquisition-sdk.ts b/src/test/acquisition-sdk.ts index fab6e52a..18aa86f8 100644 --- a/src/test/acquisition-sdk.ts +++ b/src/test/acquisition-sdk.ts @@ -229,6 +229,7 @@ describe("Acquisition SDK", () => { done(); })); }); + it("disables api calls on unsuccessful response", (done: Mocha.Done): void => { var invalidJsonResponse: acquisitionSdk.Http.Response = { statusCode: 404, @@ -249,7 +250,6 @@ describe("Acquisition SDK", () => { assert.strictEqual(returnPackage, null); acquisition = new acquisitionSdk.AcquisitionManager(new mockApi.HttpRequester(404), configuration); (acquisitionSdk.AcquisitionManager as any)._apiCallsDisabled = false; - }); acquisition.reportStatusDeploy(templateCurrentPackage, acquisitionSdk.AcquisitionStatus.DeploymentSucceeded, "1.5.0", mockApi.validDeploymentKey, ((error: Error, parameter: void): void => { @@ -266,6 +266,7 @@ describe("Acquisition SDK", () => { done(); }) + it("doesn't disable api calls on successful response", (done: Mocha.Done): void => { var acquisition = new acquisitionSdk.AcquisitionManager(new mockApi.HttpRequester(), configuration); mockApi.serverUrl = "https://codepush.appcenter.ms";