Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit ad3cd21

Browse files
committed
a few bugfixes
1 parent 89d5c14 commit ad3cd21

File tree

6 files changed

+32
-26
lines changed

6 files changed

+32
-26
lines changed

CodePush.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
44
import { Alert } from "./AlertAdapter";
5-
import requestFetchAdapter from "./request-fetch-adapter.js";
5+
import requestFetchAdapter from "./request-fetch-adapter";
66
import semver from "semver";
77

8-
const NativeCodePush = require("react-native").NativeModules.CodePush;
8+
let NativeCodePush = require("react-native").NativeModules.CodePush;
99
const PackageMixins = require("./package-mixins")(NativeCodePush);
1010

1111
async function checkForUpdate(deploymentKey = null) {
@@ -258,7 +258,7 @@ async function sync(options = {}, syncStatusChangeCallback, downloadProgressCall
258258
}
259259
};
260260

261-
export default {
261+
const CodePush = {
262262
AcquisitionSdk: Sdk,
263263
checkForUpdate,
264264
getConfiguration,
@@ -294,3 +294,5 @@ export default {
294294
title: "Update available"
295295
}
296296
};
297+
298+
export default CodePush;

Examples/CodePushDemoApp/CodePushDemoAppTests/CheckForUpdateTests/testcases/FirstUpdateTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ let FirstUpdateTest = createTestCaseComponent(
2323
};
2424
},
2525
async () => {
26-
let update = await CodePush.checkForUpdate()
27-
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote), "checkForUpdate did not return the update from the server");
26+
let update = await CodePush.checkForUpdate();
27+
assert.equal(JSON.stringify(update), JSON.stringify({ ...serverPackage, ...PackageMixins.remote, failedInstall: false }), "checkForUpdate did not return the update from the server");
2828
}
2929
);
3030

Examples/CodePushDemoApp/CodePushDemoAppTests/CheckForUpdateTests/testcases/NewUpdateTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ let NewUpdateTest = createTestCaseComponent(
2222
};
2323
},
2424
async () => {
25-
let update = await CodePush.checkForUpdate()
26-
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote), "checkForUpdate did not return the update from the server");
25+
let update = await CodePush.checkForUpdate();
26+
assert.equal(JSON.stringify(update), JSON.stringify({ ...serverPackage, ...PackageMixins.remote, failedInstall: false }), "checkForUpdate did not return the update from the server");
2727
}
2828
);
2929

Examples/CodePushDemoApp/CodePushDemoAppTests/CheckForUpdateTests/testcases/RemotePackageAppVersionNewerTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let RemotePackageAppVersionNewerTest = createTestCaseComponent(
2323
};
2424
},
2525
async () => {
26-
let update = await CodePush.checkForUpdate()
26+
let update = await CodePush.checkForUpdate();
2727
assert(!update, "checkForUpdate should not return an update if remote package is of a different binary version");
2828
}
2929
);

Examples/CodePushDemoApp/CodePushDemoAppTests/CheckForUpdateTests/testcases/SwitchDeploymentKeyTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ let SwitchDeploymentKeyTest = createTestCaseComponent(
2424
};
2525
},
2626
async () => {
27-
let update = await CodePush.checkForUpdate(deploymentKey)
28-
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote), "checkForUpdate did not return the update from the server");
27+
let update = await CodePush.checkForUpdate(deploymentKey);
28+
assert.equal(JSON.stringify(update), JSON.stringify({ ...serverPackage, ...PackageMixins.remote, failedInstall: false }), "checkForUpdate did not return the update from the server");
2929
}
3030
);
3131

request-fetch-adapter.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
let request = async (verb, url, body, callback) => {
1+
"use strict";
2+
3+
export default {
4+
async request(verb, url, body, callback) {
25
if (typeof body === "function") {
3-
callback = body;
4-
body = null;
6+
callback = body;
7+
body = null;
58
}
69

710
var headers = {
8-
"Accept": "application/json",
9-
"Content-Type": "application/json"
11+
"Accept": "application/json",
12+
"Content-Type": "application/json"
1013
};
1114

1215
if (body && typeof body === "object") {
13-
body = JSON.stringify(body);
16+
body = JSON.stringify(body);
1417
}
1518

1619
try {
17-
const response = await fetch(url, {
18-
method: verb,
19-
headers: headers,
20-
body: body
21-
});
20+
const response = await fetch(url, {
21+
method: verb,
22+
headers: headers,
23+
body: body
24+
});
2225

23-
const statusCode = response.status;
24-
const body = await response.text();
25-
callback(null, { statusCode, body });
26+
const statusCode = response.status;
27+
const body = await response.text();
28+
callback(null, { statusCode, body });
2629
} catch (err) {
27-
callback(err);
30+
callback(err);
2831
}
29-
}
32+
}
33+
};

0 commit comments

Comments
 (0)