Files
react-native-code-push/Examples/CodePushDemoApp/CodePushDemoAppTests/InstallUpdateTests/testcases/IsPendingTest.js
Geoffrey Goh 32dea6bf68 feedback
2015-12-18 16:37:28 -08:00

41 lines
1.8 KiB
JavaScript

"use strict";
import React from "react-native";
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
import CodePush from "react-native-code-push";
let NativeCodePush = React.NativeModules.CodePush;
import createTestCaseComponent from "../../utils/createTestCaseComponent";
let PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
import assert from "assert";
let remotePackage = require("../resources/remotePackage");
let IsPendingTest = createTestCaseComponent(
"IsPendingTest",
"After the app is installed, the isPending property on the installed 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.codePushInstallModeOnNextRestart);
})
.then((localPackage) => {
assert(localPackage.isPending, "isPending should be set to \"true\" after an install");
return CodePush.getCurrentPackage();
})
.then((localPackage) => {
assert(localPackage.isPending, "isPending should be set to \"true\" after an install");
});
}
);
AppRegistry.registerComponent("IsPendingTest", () => IsPendingTest);