add tests

This commit is contained in:
Geoffrey Goh
2015-12-18 00:08:11 -08:00
parent 61f83fde0d
commit bc52e8f0c5
58 changed files with 58127 additions and 1074 deletions

View File

@@ -1,66 +0,0 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
TouchableOpacity,
View,
} = React;
var RCTTestModule = require('NativeModules').TestModule;
var NativeCodePush = require('react-native').NativeModules.CodePush;
var CodePushDemoApp = React.createClass({
componentDidMount: function() {
NativeCodePush.setUsingTestFolder(true);
NativeCodePush.getCurrentPackage().then(
(savedPackage) => {
if (savedPackage) {
var testPackage = require("./TestPackage");
for (var key in testPackage) {
if (savedPackage[key] !== testPackage[key]) {
throw new Error("The local package is still different from the updated package after installation");
}
}
} else {
throw new Error("The updated package was not saved");
}
},
(err) => {
throw new Error("The updated package was not saved");
}
);
},
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
If you see this, you have successfully installed an update!
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
}
});
CodePushDemoApp.displayName = 'CodePushDemoApp';
AppRegistry.registerComponent('CodePushDemoApp', () => CodePushDemoApp);

View File

@@ -1,72 +0,0 @@
'use strict';
var React = require('react-native');
var CodePushSdk = require('react-native-code-push');
var NativeCodePush = require("react-native").NativeModules.CodePush;
var RCTTestModule = require('NativeModules').TestModule || {};
var {
AppRegistry,
Text,
View,
} = React;
var DownloadAndInstallUpdateTest = React.createClass({
propTypes: {
shouldThrow: React.PropTypes.bool,
waitOneFrame: React.PropTypes.bool,
},
getInitialState() {
return {
done: false,
};
},
componentDidMount() {
if (this.props.waitOneFrame) {
requestAnimationFrame(this.runTest);
} else {
this.setUp();
this.runTest();
}
},
setUp(callWhenDone) {
var mockConfiguration = { appVersion : "1.5.0" };
NativeCodePush.setUsingTestFolder(true);
CodePushSdk.setUpTestDependencies(null, mockConfiguration, NativeCodePush);
},
runTest() {
var update = require("./TestPackage");
NativeCodePush.downloadUpdate(update).done((downloadedPackage) => {
NativeCodePush.installUpdate(downloadedPackage, /*rollbackTimeout*/ 1000, CodePushSdk.InstallMode.IMMEDIATE)
.then(() => {
CodePushSdk.getCurrentPackage().then((localPackage) => {
if (localPackage.packageHash == update.packageHash) {
this.setState({done: true}, RCTTestModule.markTestCompleted);
} else {
throw new Error("Update was not installed");
}
});
});
});
},
render() {
return (
<View style={{backgroundColor: 'white', padding: 40}}>
<Text>
{this.constructor.displayName + ': '}
{this.state.done ? 'Done' : 'Testing...'}
</Text>
</View>
);
}
});
DownloadAndInstallUpdateTest.displayName = 'DownloadAndInstallUpdateTest';
AppRegistry.registerComponent('CodePushDemoApp', () => DownloadAndInstallUpdateTest);
module.exports = DownloadAndInstallUpdateTest;

View File

@@ -1,79 +0,0 @@
'use strict';
var React = require('react-native');
var {
AppRegistry,
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
} = React;
var TESTS = [
require('./DownloadAndInstallUpdateTest')
];
TESTS.forEach(
(test) => AppRegistry.registerComponent(test.displayName, () => test)
);
var InstallUpdateTestApp = React.createClass({
getInitialState: function() {
return {
test: null,
};
},
render: function() {
if (this.state.test) {
return (
<ScrollView>
<this.state.test />
</ScrollView>
);
}
return (
<View style={styles.container}>
<Text style={styles.row}>
Click on a test to run it in this shell for easier debugging and
development. Run all tests in the testing environment with cmd+U in
Xcode.
</Text>
<View style={styles.separator} />
<ScrollView>
{TESTS.map((test) => [
<TouchableOpacity
onPress={() => this.setState({test})}
style={styles.row}>
<Text style={styles.testName}>
{test.displayName}
</Text>
</TouchableOpacity>,
<View style={styles.separator} />
])}
</ScrollView>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
backgroundColor: 'white',
marginTop: 40,
margin: 15,
},
row: {
padding: 10,
},
testName: {
fontWeight: '500',
},
separator: {
height: 1,
backgroundColor: '#bbbbbb',
}
});
AppRegistry.registerComponent('InstallUpdateTestApp', () => InstallUpdateTestApp);

View File

@@ -1,21 +0,0 @@
var { Platform } = require("react-native");
var testPackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
if (Platform.OS === "android") {
// Genymotion forwards 10.0.3.2 to host machine's localhost
testPackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/CodePushDemoApp.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
testPackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/CodePushDemoApp.includeRequire.runModule.bundle?platform=ios&dev=true"
}
module.exports = testPackage;

View File

@@ -0,0 +1,42 @@
"use strict";
var React = require("react-native");
var CodePush = require("react-native-code-push");
var {
AppRegistry,
Text,
View,
} = React;
var IsFirstRunTest = React.createClass({
getInitialState() {
return {};
},
componentDidMount() {
CodePush.getCurrentPackage()
.then((localPackage) => {
if (localPackage.isFirstRun) {
this.setState({ passed: true });
} else {
this.setState({ passed: false });
}
});
},
render() {
var text = "Testing...";
if (this.state.passed !== undefined) {
text = this.state.passed ? "Test Passed!" : "Test Failed!";
}
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
{text}
</Text>
</View>
);
}
});
AppRegistry.registerComponent("IsFirstRunTest", () => IsFirstRunTest);

View File

@@ -0,0 +1,73 @@
"use strict";
var React = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var createMockAcquisitionSdk = require("../../utils/mockAcquisitionSdk");
var {
AppRegistry,
Platform,
Text,
View,
} = React;
var IsFailedUpdateTest = React.createClass({
getInitialState() {
return {};
},
componentDidMount() {
var serverPackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash241",
packageSize: 1024
};
if (Platform.OS === "android") {
serverPackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV2.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
serverPackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV2.includeRequire.runModule.bundle?platform=ios&dev=true"
}
var mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage);
var mockConfiguration = { appVersion : "1.5.0" };
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
CodePush.notifyApplicationReady()
.then(() => {
return CodePush.checkForUpdate();
})
.then((remotePackage) => {
if (remotePackage.failedInstall) {
this.setState({ passed: true });
} else {
return remotePackage.download();
}
})
.then((localPackage) => {
return localPackage && localPackage.install(NativeCodePush.codePushInstallModeImmediate);
});
},
render() {
var text = "Testing...";
if (this.state.passed !== undefined) {
text = this.state.passed ? "Test Passed!" : "Test Failed!";
}
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
{text}
</Text>
</View>
);
}
});
AppRegistry.registerComponent("IsFailedUpdateTest", () => IsFailedUpdateTest);

View File

@@ -0,0 +1,27 @@
"use strict";
var React = require("react-native");
var CodePush = require("react-native-code-push");
var {
AppRegistry,
Text,
View,
} = React;
var IsFailedUpdateTest = React.createClass({
componentDidMount() {
CodePush.restartApp();
},
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Testing...
</Text>
</View>
);
}
});
AppRegistry.registerComponent("IsFailedUpdateTest", () => IsFailedUpdateTest);

View File

@@ -0,0 +1,43 @@
"use strict";
var React = require("react-native");
var { Platform } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var RCTTestModule = React.NativeModules.TestModule;
var {
AppRegistry,
Text,
View,
} = React;
var NotifyApplicationReadyTest = React.createClass({
getInitialState() {
return {};
},
componentDidMount() {
CodePush.notifyApplicationReady()
.then(() => {
if (Platform.OS === "android") {
return NativeCodePush.downloadAndReplaceCurrentBundle("http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassNotifyApplicationReadyTest.includeRequire.runModule.bundle?platform=android&dev=true");
} else if (Platform.OS === "ios") {
return NativeCodePush.downloadAndReplaceCurrentBundle("http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassNotifyApplicationReadyTest.includeRequire.runModule.bundle?platform=ios&dev=true");
}
})
.then(() => {
CodePush.restartApp();
});
},
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Testing...
</Text>
</View>
);
}
});
AppRegistry.registerComponent("NotifyApplicationReadyTest", () => NotifyApplicationReadyTest);

View File

@@ -0,0 +1,23 @@
"use strict";
var React = require("react-native");
var {
AppRegistry,
Text,
View,
} = React;
var InstallModeImmediateTest = React.createClass({
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Test Passed!
</Text>
</View>
);
}
});
AppRegistry.registerComponent("InstallModeImmediateTest", () => InstallModeImmediateTest);

View File

@@ -0,0 +1,23 @@
"use strict";
var React = require("react-native");
var {
AppRegistry,
Text,
View,
} = React;
var InstallModeOnNextRestartTest = React.createClass({
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Test Passed!
</Text>
</View>
);
}
});
AppRegistry.registerComponent("InstallModeOnNextRestartTest", () => InstallModeOnNextRestartTest);

View File

@@ -0,0 +1,23 @@
"use strict";
var React = require("react-native");
var {
AppRegistry,
Text,
View,
} = React;
var InstallModeOnNextResumeTest = React.createClass({
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Test Passed!
</Text>
</View>
);
}
});
AppRegistry.registerComponent("InstallModeOnNextResumeTest", () => InstallModeOnNextResumeTest);

View File

@@ -0,0 +1,23 @@
"use strict";
var React = require("react-native");
var {
AppRegistry,
Text,
View,
} = React;
var NotifyApplicationReadyTest = React.createClass({
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Test Passed!
</Text>
</View>
);
}
});
AppRegistry.registerComponent("NotifyApplicationReadyTest", () => NotifyApplicationReadyTest);

View File

@@ -0,0 +1,61 @@
"use strict";
var React = require("react-native");
var CodePush = require("react-native-code-push");
var RCTTestModule = React.NativeModules.TestModule;
var NativeCodePush = React.NativeModules.CodePush;
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var {
AppRegistry,
Platform,
Text,
View,
} = React;
var RollbackTest = React.createClass({
componentDidMount() {
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash241",
packageSize: 1024
};
if (Platform.OS === "android") {
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV2.includeRequire.runModule.bundle?platform=android&dev=true"
CodePush.notifyApplicationReady()
.then(() => {
NativeCodePush.downloadAndReplaceCurrentBundle("http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1Pass.includeRequire.runModule.bundle?platform=android&dev=true");
});
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV2.includeRequire.runModule.bundle?platform=ios&dev=true"
CodePush.notifyApplicationReady()
.then(() => {
NativeCodePush.downloadAndReplaceCurrentBundle("http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1Pass.includeRequire.runModule.bundle?platform=ios&dev=true");
});
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
});
},
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Testing...
</Text>
</View>
);
}
});
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);

View File

@@ -0,0 +1,23 @@
"use strict";
var React = require("react-native");
var {
AppRegistry,
Text,
View,
} = React;
var RollbackTest = React.createClass({
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Test Passed!
</Text>
</View>
);
}
});
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);

View File

@@ -0,0 +1,27 @@
"use strict";
var React = require("react-native");
var CodePush = require("react-native-code-push");
var {
AppRegistry,
Text,
View,
} = React;
var RollbackTest = React.createClass({
componentDidMount() {
CodePush.restartApp();
},
render() {
return (
<View style={{backgroundColor: "white", padding: 40}}>
<Text>
Testing...
</Text>
</View>
);
}
});
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);

View File

@@ -0,0 +1,44 @@
"use strict";
var React = require("react-native");
var { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var createTestCaseComponent = require("../../utils/createTestCaseComponent");
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var assert = require("assert");
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
var InstallModeImmediateTest = createTestCaseComponent(
"InstallModeImmediateTest",
"App should restart immediately to the new version after it is installed",
() => {
if (Platform.OS === "android") {
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeImmediateTest.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeImmediateTest.includeRequire.runModule.bundle?platform=ios&dev=true"
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
return Promise.resolve();
},
() => {
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
});
},
/*passAfterRun*/ false
);
AppRegistry.registerComponent("InstallModeImmediateTest", () => InstallModeImmediateTest);

View File

@@ -0,0 +1,48 @@
"use strict";
var React = require("react-native");
var { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var createTestCaseComponent = require("../../utils/createTestCaseComponent");
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var assert = require("assert");
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
var InstallModeOnNextRestartTest = createTestCaseComponent(
"InstallModeOnNextRestartTest",
"App should boot up the new version after it is installed and restarted",
() => {
if (Platform.OS === "android") {
// Genymotion forwards 10.0.3.2 to host machine's localhost
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextRestartTest.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextRestartTest.includeRequire.runModule.bundle?platform=ios&dev=true"
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
return Promise.resolve();
},
() => {
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeOnNextRestart);
})
.then(() => {
CodePush.restartApp();
});
},
/*passAfterRun*/ false
);
AppRegistry.registerComponent("InstallModeOnNextRestartTest", () => InstallModeOnNextRestartTest);

View File

@@ -0,0 +1,47 @@
"use strict";
var React = require("react-native");
var { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var createTestCaseComponent = require("../../utils/createTestCaseComponent");
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var assert = require("assert");
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
var InstallModeOnNextResumeTest = createTestCaseComponent(
"InstallModeOnNextResumeTest",
"App should boot up the new version after it is installed and resumed",
() => {
if (Platform.OS === "android") {
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextResumeTest.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextResumeTest.includeRequire.runModule.bundle?platform=ios&dev=true"
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
return Promise.resolve();
},
() => {
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeOnNextResume);
})
.then(() => {
CodePush.restartApp();
});
},
/*passAfterRun*/ false
);
AppRegistry.registerComponent("InstallModeOnNextResumeTest", () => InstallModeOnNextResumeTest);

View File

@@ -0,0 +1,44 @@
"use strict";
var React = require("react-native");
var { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var createTestCaseComponent = require("../../utils/createTestCaseComponent");
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var assert = require("assert");
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
var IsFailedUpdateTest = createTestCaseComponent(
"IsFailedUpdateTest",
"After an installed update is rolled back, checkForUpdate should return a package with the failedInstall property set to \"true\"",
() => {
if (Platform.OS === "android") {
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV1.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV1.includeRequire.runModule.bundle?platform=ios&dev=true"
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
return Promise.resolve();
},
() => {
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
});
},
/*passAfterRun*/ false
);
AppRegistry.registerComponent("IsFailedUpdateTest", () => IsFailedUpdateTest);

View File

@@ -0,0 +1,44 @@
"use strict";
var React = require("react-native");
var { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var createTestCaseComponent = require("../../utils/createTestCaseComponent");
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var assert = require("assert");
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
var IsFirstRunTest = createTestCaseComponent(
"IsFirstRunTest",
"After the app is installed, the isFirstRun property on the current package should be set to \"true\"",
() => {
if (Platform.OS === "android") {
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=ios&dev=true"
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
return Promise.resolve();
},
() => {
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
});
},
/*passAfterRun*/ false
);
AppRegistry.registerComponent("IsFirstRunTest", () => IsFirstRunTest);

View File

@@ -0,0 +1,44 @@
"use strict";
var React = require("react-native");
var { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var createTestCaseComponent = require("../../utils/createTestCaseComponent");
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var assert = require("assert");
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
var NotifyApplicationReadyTest = createTestCaseComponent(
"NotifyApplicationReadyTest",
"After an update, the app should remain using the installed version after multiple restarts if \"notifyApplicationReady\" is called.",
() => {
if (Platform.OS === "android") {
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/NotifyApplicationReadyAndRestart.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/NotifyApplicationReadyAndRestart.includeRequire.runModule.bundle?platform=ios&dev=true"
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
return Promise.resolve();
},
() => {
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
});
},
/*passAfterRun*/ false
);
AppRegistry.registerComponent("NotifyApplicationReadyTest", () => NotifyApplicationReadyTest);

View File

@@ -0,0 +1,44 @@
"use strict";
var React = require("react-native");
var { DeviceEventEmitter, Platform, AppRegistry } = require("react-native");
var CodePush = require("react-native-code-push");
var NativeCodePush = React.NativeModules.CodePush;
var createTestCaseComponent = require("../../utils/createTestCaseComponent");
var PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
var assert = require("assert");
var remotePackage = {
description: "Angry flappy birds",
appVersion: "1.5.0",
label: "2.4.0",
isMandatory: false,
isAvailable: true,
updateAppVersion: false,
packageHash: "hash240",
packageSize: 1024
};
var RollbackTest = createTestCaseComponent(
"RollbackTest",
"should successfully rollback if \"notifyApplicationReady\" is not called in the installed package.",
() => {
if (Platform.OS === "android") {
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1.includeRequire.runModule.bundle?platform=android&dev=true"
} else if (Platform.OS === "ios") {
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1.includeRequire.runModule.bundle?platform=ios&dev=true"
}
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
return Promise.resolve();
},
() => {
remotePackage.download()
.then((localPackage) => {
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
});
},
/*passAfterRun*/ false
);
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);