change UPDATE_INSTALLED behaviour

This commit is contained in:
Geoffrey Goh
2015-11-18 15:27:05 -08:00
parent d4153d294c
commit 9fdaf510fb
6 changed files with 35 additions and 17 deletions

View File

@@ -27,7 +27,7 @@
- (void)setUp
{
app = @"CodePushDemoAppTests/InstallUpdateTests/InstallUpdateTestApp.ios";
app = @"CodePushDemoAppTests/InstallUpdateTests/DownloadAndInstallUpdateTest";
#if __LP64__
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
#endif
@@ -68,9 +68,12 @@
moduleProvider:nil
launchOptions:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"DownloadAndInstallUpdateTest"
moduleName:@"CodePushDemoApp"
initialProperties:nil];
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
rootViewController.view = rootView;
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;
@@ -98,8 +101,9 @@
}];
}
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
NSLog(foundElement ? @"Yes" : @"No");
XCTAssertTrue(foundElement, @"Cound't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
}

View File

@@ -62,4 +62,5 @@ var styles = StyleSheet.create({
}
});
CodePushDemoApp.displayName = 'CodePushDemoApp';
AppRegistry.registerComponent('CodePushDemoApp', () => CodePushDemoApp);

View File

@@ -5,6 +5,7 @@ var CodePushSdk = require('react-native-code-push');
var NativeBridge = require('react-native').NativeModules.CodePush;
var {
AppRegistry,
Text,
View,
} = React;
@@ -39,7 +40,10 @@ var DownloadAndInstallUpdateTest = React.createClass({
runTest() {
var update = require("./TestPackage");
NativeBridge.downloadUpdate(update).done((downloadedPackage) => {
NativeBridge.installUpdate(downloadedPackage, /*rollbackTimeout*/ 1000, CodePushSdk.InstallMode.IMMEDIATE);
NativeBridge.installUpdate(downloadedPackage, /*rollbackTimeout*/ 1000, CodePushSdk.InstallMode.IMMEDIATE)
.then(() => {
NativeBridge.restartApp(/*rollbackTimeout*/ 1000);
});
});
},
@@ -56,5 +60,6 @@ var DownloadAndInstallUpdateTest = React.createClass({
});
DownloadAndInstallUpdateTest.displayName = 'DownloadAndInstallUpdateTest';
AppRegistry.registerComponent('CodePushDemoApp', () => DownloadAndInstallUpdateTest);
module.exports = DownloadAndInstallUpdateTest;