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

Commit a3f5ea1

Browse files
committed
add isPending test
1 parent a09c980 commit a3f5ea1

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

Examples/CodePushDemoApp/CodePushDemoAppTests/InstallUpdateTests.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ - (void)testIsFailedUpdate
6565
[self runTest:@"IsFailedUpdateTest"];
6666
}
6767

68+
- (void)testIsPending
69+
{
70+
[self runTest:@"IsPendingTest"];
71+
}
72+
6873
- (void)runTest:(NSString *)testName
6974
{
7075
[CodePush clearTestUpdates];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"use strict";
2+
3+
import React from "react-native";
4+
let { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
5+
import CodePush from "react-native-code-push";
6+
let NativeCodePush = React.NativeModules.CodePush;
7+
import createTestCaseComponent from "../../utils/createTestCaseComponent";
8+
let PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
9+
import assert from "assert";
10+
11+
let remotePackage = {
12+
description: "Angry flappy birds",
13+
appVersion: "1.5.0",
14+
label: "2.4.0",
15+
isMandatory: false,
16+
isAvailable: true,
17+
updateAppVersion: false,
18+
packageHash: "hash240",
19+
packageSize: 1024
20+
};
21+
22+
let IsPendingTest = createTestCaseComponent(
23+
"IsPendingTest",
24+
"After the app is installed, the isPending property on the installed package should be set to \"true\"",
25+
() => {
26+
if (Platform.OS === "android") {
27+
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=android&dev=true"
28+
} else if (Platform.OS === "ios") {
29+
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=ios&dev=true"
30+
}
31+
32+
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
33+
return Promise.resolve();
34+
},
35+
() => {
36+
remotePackage.download()
37+
.then((localPackage) => {
38+
return localPackage.install(NativeCodePush.codePushInstallModeOnNextRestart);
39+
})
40+
.then((localPackage) => {
41+
assert(localPackage.isPending, "isPending should be set to \"true\" after an install");
42+
});
43+
}
44+
);
45+
46+
AppRegistry.registerComponent("IsPendingTest", () => IsPendingTest);

Examples/CodePushDemoApp/CodePushDemoAppTests/utils/createTestCaseComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function createTestCaseComponent(displayName, description, setUp, runTest, passA
4040
return (
4141
<View style={{backgroundColor: "white", padding: 40}}>
4242
<Text>
43-
{this.state.done ? "Done" : "Testing..."}
43+
{this.state.done ? "Test Passed!" : "Testing..."}
4444
</Text>
4545
</View>
4646
);

0 commit comments

Comments
 (0)