mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-16 02:44:33 +08:00
add tests
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user