mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 23:59:42 +08:00
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
import React 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";
|
|
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
|
|
|
let 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
|
|
};
|
|
|
|
let localPackage = serverPackage;
|
|
|
|
let SamePackageTest = createTestCaseComponent(
|
|
"SamePackageTest",
|
|
"should not return an update when the server's version is the same as the local version",
|
|
() => {
|
|
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
|
let mockConfiguration = { appVersion : "1.5.0" };
|
|
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
|
CodePush.getCurrentPackage = () => {
|
|
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; |