forked from microsoft/react-native-code-push
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewUpdateTest.js
More file actions
30 lines (26 loc) · 1.24 KB
/
NewUpdateTest.js
File metadata and controls
30 lines (26 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"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;