mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
import React from "react-native";
|
|
import CodePush from "react-native-code-push";
|
|
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
|
import assert from "assert";
|
|
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
|
import { serverPackage, localPackage } from "../resources/testPackages";
|
|
|
|
const NativeCodePush = React.NativeModules.CodePush;
|
|
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
|
|
|
let NewUpdateTest = createTestCaseComponent(
|
|
"NewUpdateTest",
|
|
"should return an update when server has a package that is newer than the current one",
|
|
() => {
|
|
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
|
let mockConfiguration = { appVersion : "1.5.0" };
|
|
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
|
CodePush.getCurrentPackage = async () => {
|
|
return localPackage;
|
|
};
|
|
},
|
|
async () => {
|
|
let update = await CodePush.checkForUpdate();
|
|
assert.equal(JSON.stringify(update), JSON.stringify({ ...serverPackage, ...PackageMixins.remote(), failedInstall: false }), "checkForUpdate did not return the update from the server");
|
|
}
|
|
);
|
|
|
|
module.exports = NewUpdateTest; |