mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-11 08:04:23 +08:00
add tests
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <RCTTest/RCTTestRunner.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "CodePush.h"
|
||||
|
||||
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
|
||||
|
||||
@interface CheckForUpdateTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation CheckForUpdateTests
|
||||
{
|
||||
RCTTestRunner *_runner;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
#if __LP64__
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
#endif
|
||||
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
[CodePush setUsingTestConfiguration:YES];
|
||||
[CodePush clearTestUpdates];
|
||||
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/CheckForUpdateTests/CheckForUpdateTestApp", nil);
|
||||
}
|
||||
|
||||
#pragma mark Logic Tests
|
||||
|
||||
- (void)testFirstUpdate
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"FirstUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)testNewUpdate
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"NewUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)testNoRemotePackage
|
||||
{
|
||||
|
||||
[_runner runTest:_cmd module:@"NoRemotePackageTest"];
|
||||
}
|
||||
|
||||
- (void)testRemotePackageAppVersionNewer
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"RemotePackageAppVersionNewerTest"];
|
||||
}
|
||||
|
||||
- (void)testSamePackage
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"SamePackageTest"];
|
||||
}
|
||||
|
||||
- (void)testSwitchDeploymentKey
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"SwitchDeploymentKeyTest"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var React = require('react-native');
|
||||
var React = require("react-native");
|
||||
|
||||
var {
|
||||
AppRegistry,
|
||||
@@ -12,24 +12,25 @@ var {
|
||||
} = React;
|
||||
|
||||
var TESTS = [
|
||||
require('./NoRemotePackageTest'),
|
||||
require('./NoRemotePackageWithSameAppVersionTest'),
|
||||
require('./FirstUpdateTest'),
|
||||
require('./NewUpdateTest'),
|
||||
require('./SamePackageTest')
|
||||
require("./testcases/FirstUpdateTest"),
|
||||
require("./testcases/NewUpdateTest"),
|
||||
require("./testcases/NoRemotePackageTest"),
|
||||
require("./testcases/RemotePackageAppVersionNewerTest"),
|
||||
require("./testcases/SamePackageTest"),
|
||||
require("./testcases/SwitchDeploymentKeyTest")
|
||||
];
|
||||
|
||||
TESTS.forEach(
|
||||
(test) => AppRegistry.registerComponent(test.displayName, () => test)
|
||||
);
|
||||
|
||||
var QueryUpdateTestApp = React.createClass({
|
||||
getInitialState: function() {
|
||||
var CheckForUpdateTestApp = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
test: null,
|
||||
};
|
||||
},
|
||||
render: function() {
|
||||
render() {
|
||||
if (this.state.test) {
|
||||
return (
|
||||
<ScrollView>
|
||||
@@ -40,9 +41,7 @@ var QueryUpdateTestApp = React.createClass({
|
||||
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.
|
||||
CheckForUpdate Tests
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
@@ -53,6 +52,9 @@ var QueryUpdateTestApp = React.createClass({
|
||||
<Text style={styles.testName}>
|
||||
{test.displayName}
|
||||
</Text>
|
||||
<Text style={styles.testDescription}>
|
||||
{test.description}
|
||||
</Text>
|
||||
</TouchableOpacity>,
|
||||
<View style={styles.separator} />
|
||||
])}
|
||||
@@ -64,7 +66,7 @@ var QueryUpdateTestApp = React.createClass({
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
backgroundColor: "white",
|
||||
marginTop: 40,
|
||||
margin: 15,
|
||||
},
|
||||
@@ -72,12 +74,15 @@ var styles = StyleSheet.create({
|
||||
padding: 10,
|
||||
},
|
||||
testName: {
|
||||
fontWeight: '500',
|
||||
fontWeight: "500",
|
||||
},
|
||||
testDescription: {
|
||||
fontSize: 10
|
||||
},
|
||||
separator: {
|
||||
height: 1,
|
||||
backgroundColor: '#bbbbbb',
|
||||
backgroundColor: "#bbbbbb",
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('QueryUpdateTestApp', () => QueryUpdateTestApp);
|
||||
AppRegistry.registerComponent("CheckForUpdateTestApp", () => CheckForUpdateTestApp);
|
||||
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
var React = 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 createMockAcquisitionSdk = require("../../utils/mockAcquisitionSdk");
|
||||
|
||||
var serverPackage = {
|
||||
appVersion: "1.5.0",
|
||||
description: "Angry flappy birds",
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
isAvailable: true,
|
||||
isMandatory: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024,
|
||||
updateAppVersion: false
|
||||
};
|
||||
|
||||
var localPackage = {};
|
||||
|
||||
var FirstUpdateTest = createTestCaseComponent(
|
||||
"FirstUpdateTest",
|
||||
"should return an update when called from freshly installed binary if the server has one",
|
||||
() => {
|
||||
var mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote));
|
||||
} else {
|
||||
throw new Error("checkForUpdate did not return the update from the server");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = FirstUpdateTest;
|
||||
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
var React = 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 createMockAcquisitionSdk = require("../../utils/mockAcquisitionSdk");
|
||||
|
||||
var serverPackage = {
|
||||
appVersion: "1.5.0",
|
||||
description: "Angry flappy birds",
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
isAvailable: true,
|
||||
isMandatory: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024,
|
||||
updateAppVersion: false
|
||||
};
|
||||
|
||||
var localPackage = {
|
||||
downloadURL: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash123",
|
||||
packageSize: 1024
|
||||
};
|
||||
|
||||
var NewUpdateTest = createTestCaseComponent(
|
||||
"NewUpdateTest",
|
||||
"should return an update when server has a package that is newer than the current one",
|
||||
() => {
|
||||
var mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote));
|
||||
} else {
|
||||
throw new Error("checkForUpdate did not return the update from the server");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = NewUpdateTest;
|
||||
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
var React = 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 createMockAcquisitionSdk = require("../../utils/mockAcquisitionSdk");
|
||||
|
||||
var serverPackage = null;
|
||||
var localPackage = {};
|
||||
|
||||
var NoRemotePackageTest = createTestCaseComponent(
|
||||
"NoRemotePackageTest",
|
||||
"should not return an update when the server has none",
|
||||
() => {
|
||||
var mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
throw new Error("checkForUpdate should not return an update if there is none on the server");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = NoRemotePackageTest;
|
||||
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
|
||||
var React = 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 createMockAcquisitionSdk = require("../../utils/mockAcquisitionSdk");
|
||||
|
||||
var serverPackage = {
|
||||
appVersion: "1.5.0",
|
||||
description: "",
|
||||
downloadUrl: "",
|
||||
isAvailable: false,
|
||||
isMandatory: false,
|
||||
packageHash: "",
|
||||
updateAppVersion: true
|
||||
};
|
||||
|
||||
var localPackage = {};
|
||||
|
||||
var RemotePackageAppVersionNewerTest = createTestCaseComponent(
|
||||
"RemotePackageAppVersionNewerTest",
|
||||
"should drop the update when the server reports one with a newer binary version",
|
||||
() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
var mockConfiguration = { appVersion : "1.0.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
throw new Error("checkForUpdate should not return an update if remote package is of a different binary version");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = RemotePackageAppVersionNewerTest;
|
||||
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
var React = 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 createMockAcquisitionSdk = require("../../utils/mockAcquisitionSdk");
|
||||
|
||||
var serverPackage = {
|
||||
appVersion: "1.5.0",
|
||||
description: "Angry flappy birds",
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
isAvailable: true,
|
||||
isMandatory: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024,
|
||||
updateAppVersion: false
|
||||
};
|
||||
|
||||
var localPackage = serverPackage;
|
||||
|
||||
var SamePackageTest = createTestCaseComponent(
|
||||
"SamePackageTest",
|
||||
"should not return an update when the server's version is the same as the local version",
|
||||
() => {
|
||||
var mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
throw new Error("checkForUpdate should not return a package when local package is identical");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = SamePackageTest;
|
||||
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
var React = 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 createMockAcquisitionSdk = require("../../utils/mockAcquisitionSdk");
|
||||
|
||||
var serverPackage = {
|
||||
appVersion: "1.5.0",
|
||||
description: "Angry flappy birds",
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
isAvailable: true,
|
||||
isMandatory: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024,
|
||||
updateAppVersion: false
|
||||
};
|
||||
var localPackage = {};
|
||||
var deploymentKey = "myKey123";
|
||||
|
||||
var SwitchDeploymentKeyTest = createTestCaseComponent(
|
||||
"SwitchDeploymentKeyTest",
|
||||
"should check for an update under the specified deployment key",
|
||||
() => {
|
||||
var mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage, deploymentKey);
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate(deploymentKey)
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote));
|
||||
} else {
|
||||
throw new Error("checkForUpdate did not return the update from the server");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = SwitchDeploymentKeyTest;
|
||||
@@ -3,6 +3,7 @@
|
||||
#import <RCTTest/RCTTestRunner.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "CodePush.h"
|
||||
|
||||
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
|
||||
|
||||
@@ -12,25 +13,27 @@
|
||||
|
||||
@implementation DownloadProgressTests
|
||||
{
|
||||
RCTTestRunner *_runner;
|
||||
RCTTestRunner *_runner;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
#if __LP64__
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
#endif
|
||||
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/DownloadProgressTests/DownloadProgressTestApp", nil);
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
[CodePush setUsingTestConfiguration:YES];
|
||||
[CodePush clearTestUpdates];
|
||||
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/DownloadProgressTests/DownloadProgressTestApp", nil);
|
||||
}
|
||||
|
||||
#pragma mark Logic Tests
|
||||
- (void)testDownloadProgress
|
||||
{
|
||||
|
||||
[_runner runTest:_cmd module:@"DownloadProgressTest"];
|
||||
[_runner runTest:_cmd module:@"DownloadProgressTest"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var React = require("react-native");
|
||||
var { Platform, DeviceEventEmitter } = require("react-native");
|
||||
var CodePushSdk = require("react-native-code-push");
|
||||
var NativeCodePush = require("react-native").NativeModules.CodePush;
|
||||
var RCTTestModule = require('NativeModules').TestModule || {};
|
||||
|
||||
var {
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
var DownloadProgressTest = 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.runTest();
|
||||
}
|
||||
},
|
||||
|
||||
checkReceivedAndExpectedBytesEqual() {
|
||||
if (this.state.progress.receivedBytes !== this.state.progress.totalBytes) {
|
||||
throw new Error("Bytes do not tally: Received bytes=" + this.state.progress.receivedBytes + " Total bytes=" + this.state.progress.totalBytes);
|
||||
}
|
||||
},
|
||||
|
||||
runTest() {
|
||||
var downloadProgressSubscription = DeviceEventEmitter.addListener(
|
||||
"CodePushDownloadProgress",
|
||||
(progress) => {
|
||||
this.setState({
|
||||
progress:progress,
|
||||
done: false,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
var updates = require("./TestPackages");
|
||||
NativeCodePush.downloadUpdate(updates.smallPackage)
|
||||
.then((smallPackage) => {
|
||||
if (smallPackage) {
|
||||
this.checkReceivedAndExpectedBytesEqual();
|
||||
return NativeCodePush.downloadUpdate(updates.mediumPackage);
|
||||
} else {
|
||||
throw new Error("Small package download failed.");
|
||||
}
|
||||
})
|
||||
.then((mediumPackage) => {
|
||||
if (mediumPackage) {
|
||||
this.checkReceivedAndExpectedBytesEqual();
|
||||
return NativeCodePush.downloadUpdate(updates.largePackage);
|
||||
} else {
|
||||
throw new Error("Medium package download failed.");
|
||||
}
|
||||
})
|
||||
.done((largePackage) => {
|
||||
if (largePackage) {
|
||||
this.checkReceivedAndExpectedBytesEqual();
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
} else {
|
||||
throw new Error("Large package download failed.");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render() {
|
||||
var progressView;
|
||||
if (this.state.progress) {
|
||||
progressView = (
|
||||
<Text>{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received</Text>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
{this.constructor.displayName + ": "}
|
||||
{this.state.done ? "Done" : "Testing..."}
|
||||
</Text>
|
||||
{progressView}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
DownloadProgressTest.displayName = "DownloadProgressTest";
|
||||
|
||||
module.exports = DownloadProgressTest;
|
||||
@@ -12,7 +12,7 @@ var {
|
||||
} = React;
|
||||
|
||||
var TESTS = [
|
||||
require("./DownloadProgressTest")
|
||||
require("./testcases/DownloadProgressTest")
|
||||
];
|
||||
|
||||
TESTS.forEach(
|
||||
@@ -20,12 +20,12 @@ TESTS.forEach(
|
||||
);
|
||||
|
||||
var DownloadProgressTestApp = React.createClass({
|
||||
getInitialState: function() {
|
||||
getInitialState() {
|
||||
return {
|
||||
test: null,
|
||||
};
|
||||
},
|
||||
render: function() {
|
||||
render() {
|
||||
if (this.state.test) {
|
||||
return (
|
||||
<ScrollView>
|
||||
@@ -36,9 +36,7 @@ var DownloadProgressTestApp = React.createClass({
|
||||
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.
|
||||
DownloadProgress Tests
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
@@ -49,6 +47,9 @@ var DownloadProgressTestApp = React.createClass({
|
||||
<Text style={styles.testName}>
|
||||
{test.displayName}
|
||||
</Text>
|
||||
<Text style={styles.testDescription}>
|
||||
{test.description}
|
||||
</Text>
|
||||
</TouchableOpacity>,
|
||||
<View style={styles.separator} />
|
||||
])}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var { Platform } = require("react-native");
|
||||
|
||||
var packages = {
|
||||
smallPackage: {
|
||||
var packages = [
|
||||
{
|
||||
downloadUrl: "smallFile",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
@@ -12,7 +12,7 @@ var packages = {
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
mediumPackage: {
|
||||
{
|
||||
downloadUrl: "mediumFile",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
@@ -23,7 +23,7 @@ var packages = {
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
largePackage: {
|
||||
{
|
||||
downloadUrl: "largeFile",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
@@ -34,15 +34,14 @@ var packages = {
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
}
|
||||
};
|
||||
];
|
||||
|
||||
for (var aPackage in packages) {
|
||||
packages.forEach((aPackage) => {
|
||||
if (Platform.OS === "android") {
|
||||
// Genymotion forwards 10.0.3.2 to host machine's localhost
|
||||
packages[aPackage].downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/DownloadProgressTests/" + packages[aPackage].downloadUrl;
|
||||
aPackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/DownloadProgressTests/resources/" + aPackage.downloadUrl;
|
||||
} else if (Platform.OS === "ios") {
|
||||
packages[aPackage].downloadUrl = "http://localhost:8081/CodePushDemoAppTests/DownloadProgressTests/" + packages[aPackage].downloadUrl;
|
||||
aPackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/DownloadProgressTests/resources/" + aPackage.downloadUrl;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = packages;
|
||||
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
var React = 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 testPackages = require("../resources/TestPackages");
|
||||
var localPackage = {};
|
||||
var saveProgress;
|
||||
|
||||
function checkReceivedAndExpectedBytesEqual() {
|
||||
assert(saveProgress, "Download progress was not reported.");
|
||||
assert.equal(
|
||||
saveProgress.receivedBytes,
|
||||
saveProgress.totalBytes,
|
||||
`Bytes do not tally: Received bytes=${saveProgress.receivedBytes} Total bytes=${saveProgress.totalBytes}`
|
||||
);
|
||||
console.log("Downloaded one package.");
|
||||
saveProgress = null;
|
||||
}
|
||||
|
||||
var DownloadProgressTest = createTestCaseComponent(
|
||||
"DownloadProgressTest",
|
||||
"should successfully download all the bytes contained in the test packages",
|
||||
() => {
|
||||
testPackages.forEach((aPackage, index) => {
|
||||
testPackages[index] = Object.assign(aPackage, PackageMixins.remote);
|
||||
});
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
var downloadProgressCallback = (downloadProgress) => {
|
||||
console.log(`Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`);
|
||||
saveProgress = downloadProgress;
|
||||
};
|
||||
|
||||
// Chains promises together.
|
||||
return testPackages.reduce((aPackageDownloaded, nextPackage, index) => {
|
||||
return aPackageDownloaded
|
||||
.then(() => {
|
||||
// Skip the first time.
|
||||
index && checkReceivedAndExpectedBytesEqual();
|
||||
return nextPackage.download(downloadProgressCallback);
|
||||
})
|
||||
}, Promise.resolve());
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = DownloadProgressTest;
|
||||
@@ -3,6 +3,9 @@
|
||||
#import <RCTTest/RCTTestRunner.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTRootView.h"
|
||||
#import "RCTText.h"
|
||||
#import "CodePush.h"
|
||||
|
||||
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
|
||||
|
||||
@@ -12,25 +15,92 @@
|
||||
|
||||
@implementation InstallUpdateTests
|
||||
{
|
||||
RCTTestRunner *_runner;
|
||||
RCTTestRunner *_runner;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
#if __LP64__
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
#endif
|
||||
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/InstallUpdateTests/InstallUpdateTestApp", nil);
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
[CodePush setUsingTestConfiguration:YES];
|
||||
}
|
||||
|
||||
#pragma mark Logic Tests
|
||||
- (void)testDownloadAndInstallUpdate
|
||||
- (void)testInstallModeImmediate
|
||||
{
|
||||
[self runTest:@"InstallModeImmediateTest"];
|
||||
}
|
||||
|
||||
- (void)testInstallModeOnNextResume
|
||||
{
|
||||
[self runTest:@"InstallModeOnNextResumeTest"];
|
||||
}
|
||||
|
||||
- (void)testInstallModeOnNextRestart
|
||||
{
|
||||
[self runTest:@"InstallModeOnNextRestartTest"];
|
||||
}
|
||||
|
||||
- (void)testIsFirstRun
|
||||
{
|
||||
[self runTest:@"IsFirstRunTest"];
|
||||
}
|
||||
|
||||
- (void)testNotifyApplicationReady
|
||||
{
|
||||
[self runTest:@"NotifyApplicationReadyTest"];
|
||||
}
|
||||
|
||||
- (void)testRollback
|
||||
{
|
||||
[self runTest:@"RollbackTest"];
|
||||
}
|
||||
|
||||
- (void)testIsFailedUpdate
|
||||
{
|
||||
[self runTest:@"IsFailedUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)runTest:(NSString *)testName
|
||||
{
|
||||
[CodePush clearTestUpdates];
|
||||
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/testcases/%@.bundle?platform=ios&dev=true", testName]]
|
||||
moduleName:testName
|
||||
initialProperties:nil
|
||||
launchOptions:nil];
|
||||
rootView.frame = CGRectMake(0, 0, 320, 2000); // Constant size for testing on multiple devices
|
||||
UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
vc.view = [UIView new];
|
||||
[vc.view addSubview:rootView];
|
||||
while (![self foundTestPassedText:vc.view]) {
|
||||
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
||||
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)foundTestPassedText:(UIView *)view {
|
||||
BOOL foundText = NO;
|
||||
NSArray *subviews = [view subviews];
|
||||
if ([subviews count] == 0) {
|
||||
if ([view isKindOfClass:[RCTText class]] && [[((RCTText *)view) textStorage].string isEqualToString:@"Test Passed!"]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
[_runner runTest:_cmd module:@"DownloadAndInstallUpdateTest"];
|
||||
for (UIView *subview in subviews) {
|
||||
foundText = [self foundTestPassedText:subview];
|
||||
if (foundText) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return foundText;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -1,61 +0,0 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <RCTTest/RCTTestRunner.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
|
||||
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
|
||||
|
||||
@interface QueryUpdateTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation QueryUpdateTests
|
||||
{
|
||||
RCTTestRunner *_runner;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
#if __LP64__
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
#endif
|
||||
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/QueryUpdateTests/QueryUpdateTestApp", nil);
|
||||
}
|
||||
|
||||
#pragma mark Logic Tests
|
||||
- (void)testNoRemotePackage
|
||||
{
|
||||
|
||||
[_runner runTest:_cmd module:@"NoRemotePackageTest"];
|
||||
}
|
||||
|
||||
- (void)testNoRemotePackageWithSameAppVersion
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"NoRemotePackageWithSameAppVersionTest"];
|
||||
}
|
||||
|
||||
- (void)testFirstUpdate
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"FirstUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)testNewUpdate
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"NewUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)testSamePackage
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"SamePackageTest"];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -1,96 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var RCTTestModule = require('NativeModules').TestModule;
|
||||
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 {
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
var FirstUpdateTest = 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 mockAcquisitionSdk = {
|
||||
latestPackage: {
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
queryUpdateWithCurrentPackage: function(queryPackage, callback){
|
||||
if (!this.latestPackage || queryPackage.appVersion !== this.latestPackage.appVersion ||
|
||||
queryPackage.packageHash == this.latestPackage.packageHash) {
|
||||
callback(/*err:*/ null, false);
|
||||
} else {
|
||||
callback(/*err:*/ null, this.latestPackage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
NativeCodePush.setUsingTestFolder(true);
|
||||
CodePushSdk.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
|
||||
CodePushSdk.getCurrentPackage = function () {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
callWhenDone();
|
||||
},
|
||||
|
||||
runTest() {
|
||||
CodePushSdk.checkForUpdate().then(
|
||||
(update) => {
|
||||
if (update) {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
} else {
|
||||
throw new Error('SDK should return a package when there is an update');
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
throw new Error(err.message);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{this.constructor.displayName + ': '}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
FirstUpdateTest.displayName = 'FirstUpdateTest';
|
||||
|
||||
module.exports = FirstUpdateTest;
|
||||
@@ -1,108 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var RCTTestModule = require('NativeModules').TestModule;
|
||||
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 {
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
var NewUpdateTest = 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 mockAcquisitionSdk = {
|
||||
latestPackage: {
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
queryUpdateWithCurrentPackage: function(queryPackage, callback){
|
||||
if (!this.latestPackage || queryPackage.appVersion !== this.latestPackage.appVersion ||
|
||||
queryPackage.packageHash == this.latestPackage.packageHash) {
|
||||
callback(/*err:*/ null, false);
|
||||
} else {
|
||||
callback(/*err:*/ null, this.latestPackage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var localPackage = {
|
||||
downloadURL: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash123",
|
||||
packageSize: 1024
|
||||
};
|
||||
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
NativeCodePush.setUsingTestFolder(true);
|
||||
CodePushSdk.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
|
||||
CodePushSdk.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
callWhenDone();
|
||||
},
|
||||
|
||||
runTest() {
|
||||
CodePushSdk.checkForUpdate().then(
|
||||
(update) => {
|
||||
if (update) {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
} else {
|
||||
throw new Error('SDK should return a package when there is a new update');
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
throw new Error(err.message);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{this.constructor.displayName + ': '}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
NewUpdateTest.displayName = 'NewUpdateTest';
|
||||
|
||||
module.exports = NewUpdateTest;
|
||||
@@ -1,81 +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 {
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
var NoRemotePackageTest = 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() {
|
||||
var mockAcquisitionSdk = {
|
||||
latestPackage: null,
|
||||
queryUpdateWithCurrentPackage: function(queryPackage, callback){
|
||||
if (!this.latestPackage || queryPackage.appVersion !== this.latestPackage.appVersion ||
|
||||
queryPackage.packageHash == this.latestPackage.packageHash) {
|
||||
callback(/*err:*/ null, false);
|
||||
} else {
|
||||
callback(/*err:*/ null, latestPackage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
NativeCodePush.setUsingTestFolder(true);
|
||||
CodePushSdk.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
},
|
||||
|
||||
runTest() {
|
||||
CodePushSdk.checkForUpdate().then(
|
||||
(update) => {
|
||||
if (update) {
|
||||
throw new Error('SDK should not return a package if remote does not contain a package');
|
||||
} else {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
throw new Error(err.message);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{this.constructor.displayName + ': '}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
NoRemotePackageTest.displayName = 'NoRemotePackageTest';
|
||||
|
||||
module.exports = NoRemotePackageTest;
|
||||
@@ -1,108 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var React = require('react-native');
|
||||
var RCTTestModule = React.NativeModules.TestModule;
|
||||
var CodePushSdk = require('react-native-code-push');
|
||||
var NativeCodePush = require("react-native").NativeModules.CodePush;
|
||||
var RCTTestModule = require('NativeModules').TestModule || {};
|
||||
|
||||
var {
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
var NoRemotePackageWithSameAppVersionTest = 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 mockAcquisitionSdk = {
|
||||
latestPackage: {
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
queryUpdateWithCurrentPackage: function(queryPackage, callback){
|
||||
if (!this.latestPackage || queryPackage.appVersion !== this.latestPackage.appVersion ||
|
||||
queryPackage.packageHash == this.latestPackage.packageHash) {
|
||||
callback(/*err:*/ null, false);
|
||||
} else {
|
||||
callback(/*err:*/ null, latestPackage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NativeCodePush.setUsingTestFolder(true);
|
||||
var localPackage = {
|
||||
downloadURL: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.0.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash123",
|
||||
packageSize: 1024
|
||||
};
|
||||
|
||||
var mockConfiguration = { appVersion : "1.0.0" };
|
||||
CodePushSdk.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
|
||||
CodePushSdk.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
callWhenDone();
|
||||
},
|
||||
|
||||
runTest() {
|
||||
CodePushSdk.checkForUpdate().then(
|
||||
(update) => {
|
||||
if (update) {
|
||||
throw new Error('SDK should not return a package if remote package is of a different version');
|
||||
} else {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
throw new Error(err.message);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{this.constructor.displayName + ': '}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
NoRemotePackageWithSameAppVersionTest.displayName = 'NoRemotePackageWithSameAppVersionTest';
|
||||
|
||||
module.exports = NoRemotePackageWithSameAppVersionTest;
|
||||
@@ -1,108 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var RCTTestModule = require('NativeModules').TestModule;
|
||||
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 {
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
var SamePackageTest = 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 mockAcquisitionSdk = {
|
||||
latestPackage: {
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
queryUpdateWithCurrentPackage: function(queryPackage, callback){
|
||||
if (!this.latestPackage || queryPackage.appVersion !== this.latestPackage.appVersion ||
|
||||
queryPackage.packageHash == this.latestPackage.packageHash) {
|
||||
callback(/*err:*/ null, false);
|
||||
} else {
|
||||
callback(/*err:*/ null, this.latestPackage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var localPackage = {
|
||||
downloadURL: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
};
|
||||
|
||||
var mockConfiguration = { appVersion : "1.5.0" };
|
||||
NativeCodePush.setUsingTestFolder(true);
|
||||
CodePushSdk.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
|
||||
CodePushSdk.getCurrentPackage = function () {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
callWhenDone();
|
||||
},
|
||||
|
||||
runTest() {
|
||||
CodePushSdk.checkForUpdate().then(
|
||||
(update) => {
|
||||
if (update) {
|
||||
throw new Error('SDK should not return a package when local package is identical');
|
||||
} else {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
throw new Error(err.message);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{this.constructor.displayName + ': '}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
SamePackageTest.displayName = 'SamePackageTest';
|
||||
|
||||
module.exports = SamePackageTest;
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Test Cases
|
||||
---
|
||||
* QueryUpdateTests - Tests the functionality of querying for new app updates via the SDK
|
||||
* CheckForUpdateTests - Tests the functionality of querying for new app updates via the SDK
|
||||
* testNoRemotePackage - Checks that when the remote server has no update packages available, CodePushSdk.queryUpdate does not return a new package nor throw an error.
|
||||
* testNoRemotePackageWithSameAppVersion - Checks that when the remote server has an update with a different appVersion, the CodePushSdk.queryUpdate does not return a new package nor throw an error.
|
||||
* testFirstUpdate - Checks that when there is no current package (for example, the current build is a fresh install from the app store) and the remote server has a new package, CodePushSdk.queryUpdate returns that new package without throwing an error.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
var React = require("react-native");
|
||||
var { DeviceEventEmitter } = require("react-native");
|
||||
var NativeCodePush = React.NativeModules.CodePush;
|
||||
|
||||
// RCTTestModule is not implemented yet for RN Android.
|
||||
var RCTTestModule = React.NativeModules.TestModule || {};
|
||||
|
||||
var {
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
function createTestCaseComponent(displayName, description, setUp, runTest, passAfterRun = true) {
|
||||
var TestCaseComponent = React.createClass({
|
||||
propTypes: {
|
||||
shouldThrow: React.PropTypes.bool,
|
||||
waitOneFrame: React.PropTypes.bool,
|
||||
},
|
||||
getInitialState() {
|
||||
return {
|
||||
done: false,
|
||||
};
|
||||
},
|
||||
componentDidMount() {
|
||||
setUp()
|
||||
.then(runTest)
|
||||
.then(() => {
|
||||
if (passAfterRun) {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
{this.state.done ? "Done" : "Testing..."}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
TestCaseComponent.displayName = displayName;
|
||||
TestCaseComponent.description = description;
|
||||
|
||||
return TestCaseComponent;
|
||||
}
|
||||
|
||||
module.exports = createTestCaseComponent;
|
||||
@@ -0,0 +1,19 @@
|
||||
var assert = require("assert");
|
||||
|
||||
function createMockAcquisitionSdk(serverPackage, localPackage, expectedDeploymentKey) {
|
||||
var AcquisitionManager = function (httpRequester, configuration) {
|
||||
expectedDeploymentKey && assert.equal(expectedDeploymentKey, configuration.deploymentKey, "checkForUpdate did not initialize Acquisition SDK with the expected deployment key");
|
||||
}
|
||||
AcquisitionManager.prototype.queryUpdateWithCurrentPackage = function (queryPackage, callback) {
|
||||
if (localPackage) {
|
||||
localPackage.appVersion = queryPackage.appVersion;
|
||||
assert.deepEqual(queryPackage, localPackage, "checkForUpdate did not attach current package info to the acquisition request");
|
||||
}
|
||||
callback(/*err:*/ null, serverPackage);
|
||||
};
|
||||
return AcquisitionManager;
|
||||
}
|
||||
|
||||
module.exports = createMockAcquisitionSdk;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user