Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
DordeDimitrijev committed Dec 2, 2024
1 parent d0cfdd2 commit 05fb0d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/test/acquisition-rest-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ 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<acquisitionSdk.Http.Response>, callback?: acquisitionSdk.Callback<acquisitionSdk.Http.Response>): void {
if (!callback && typeof requestBodyOrCallback === "function") {
callback = <acquisitionSdk.Callback<acquisitionSdk.Http.Response>>requestBodyOrCallback;
}

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");
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/acquisition-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 => {
Expand All @@ -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";
Expand Down

0 comments on commit 05fb0d4

Please sign in to comment.