Skip to content

Commit f95194f

Browse files
authored
[Tests] Clean up tests (#1787)
1 parent 2e85db6 commit f95194f

29 files changed

+109
-102
lines changed

code-push-plugin-testing-framework/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
"license": "MIT",
1717
"homepage": "https://microsoft.github.io/code-push",
1818
"dependencies": {
19+
"@types/uuid": "^3.4.7",
1920
"base-64": "^0.1.0",
2021
"mocha": "latest",
2122
"mocha-junit-reporter": "latest",
22-
"node-uuid": "^1.4.8",
2323
"q": "^1.5.1",
2424
"replace": "latest",
25-
"superagent": "^3.8.3",
26-
"superagent-proxy": "^1.0.3"
25+
"superagent": "^5.2.1",
26+
"superagent-proxy": "^1.0.3",
27+
"uuid": "^3.4.0"
2728
},
2829
"bugs": {
2930
"url": "https://github.com/Microsoft/code-push/issues"

code-push-plugin-testing-framework/script/platform.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22
var Q = require("q");
33
var testUtil_1 = require("./testUtil");
4-
var TestConfig = require("./testConfig");
54
//////////////////////////////////////////////////////////////////////////////////////////
65
// PLATFORMS
76
/**

code-push-plugin-testing-framework/script/serverUtil.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
// IMPORTS
33
var assert = require("assert");
4-
var bodyparser = require("body-parser");
4+
var bodyParser = require("body-parser");
55
var express = require("express");
66
var Q = require("q");
77
//////////////////////////////////////////////////////////////////////////////////////////
@@ -12,8 +12,8 @@ var Q = require("q");
1212
function setupServer(targetPlatform) {
1313
console.log("Setting up server at " + targetPlatform.getServerUrl());
1414
var app = express();
15-
app.use(bodyparser.json());
16-
app.use(bodyparser.urlencoded({ extended: true }));
15+
app.use(bodyParser.json());
16+
app.use(bodyParser.urlencoded({ extended: true }));
1717
app.use(function (req, res, next) {
1818
res.setHeader("Access-Control-Allow-Origin", "*");
1919
res.setHeader("Access-Control-Allow-Methods", "*");

code-push-plugin-testing-framework/script/test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ function initializeTests(projectManager, supportedTargetPlatforms, describeTests
5454
// create the test project
5555
promises.push(createTestProject(TestConfig.testRunDirectory)
5656
.then(function () {
57-
console.log("Building update project.");
58-
// create the update project
59-
return createTestProject(TestConfig.updatesDirectory);
60-
}).then(function () { return null; }));
57+
console.log("Building update project.");
58+
// create the update project
59+
return createTestProject(TestConfig.updatesDirectory);
60+
}).then(function () { return null; }));
6161
Q.all(promises).then(function () { done(); }, function (error) { done(error); });
6262
});
6363
}

code-push-plugin-testing-framework/script/testUtil.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22
var archiver = require("archiver");
33
var child_process = require("child_process");
4-
var del = require("del");
54
var fs = require("fs");
65
var replace = require("replace");
76
var Q = require("q");

test/template/codePushWrapper.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ import CodePush from "react-native-code-push";
33
// This module wraps CodePush API calls to add test message callbacks to every function for simpler test code.
44

55
module.exports = {
6-
checkForUpdate: function(testApp, onSuccess, onError, deploymentKey) {
6+
checkForUpdate: function (testApp, onSuccess, onError, deploymentKey) {
77
return CodePush.checkForUpdate(deploymentKey)
88
.then((remotePackage) => {
99
return testApp.checkUpdateSuccess(remotePackage).then(() => { return onSuccess && onSuccess(remotePackage); });
1010
}, (error) => {
1111
return testApp.checkUpdateError(error).then(() => { return onError && onError(error); });
1212
});
1313
},
14-
15-
download: function(testApp, onSuccess, onError, remotePackage) {
14+
15+
download: function (testApp, onSuccess, onError, remotePackage) {
1616
return remotePackage.download()
1717
.then((localPackage) => {
1818
return testApp.downloadSuccess(localPackage).then(() => { return onSuccess && onSuccess(localPackage); });
1919
}, (error) => {
2020
return testApp.downloadError(error).then(() => { return onError && onError(error); });
2121
});
2222
},
23-
24-
install: function(testApp, onSuccess, onError, installMode, minBackgroundDuration, localPackage) {
23+
24+
install: function (testApp, onSuccess, onError, installMode, minBackgroundDuration, localPackage) {
2525
return localPackage.install(installMode, minBackgroundDuration)
2626
.then(() => {
2727
// Since immediate installs cannot be reliably logged (due to async network calls), we only log "UPDATE_INSTALLED" if it is a resume or restart update.
@@ -31,14 +31,14 @@ module.exports = {
3131
return testApp.installError().then(() => { return onError && onError(); });
3232
});
3333
},
34-
35-
checkAndInstall: function(testApp, onSuccess, onError, installMode, minBackgroundDuration) {
34+
35+
checkAndInstall: function (testApp, onSuccess, onError, installMode, minBackgroundDuration) {
3636
var installUpdate = this.install.bind(this, testApp, onSuccess, onError, installMode, minBackgroundDuration);
3737
var downloadUpdate = this.download.bind(this, testApp, installUpdate, onError);
3838
return this.checkForUpdate(testApp, downloadUpdate, onError);
3939
},
40-
41-
sync: function(testApp, onSyncStatus, onSyncError, options) {
40+
41+
sync: function (testApp, onSyncStatus, onSyncError, options) {
4242
return CodePush.checkForUpdate()
4343
.then(
4444
(remotePackage) => {
@@ -48,7 +48,7 @@ module.exports = {
4848
var regularUpdateIsImmediate = options && options.installMode === CodePush.InstallMode.IMMEDIATE;
4949
var mandatoryUpdateIsImmediate = !options || (options && (!options.mandatoryInstallMode || options.mandatoryInstallMode === CodePush.InstallMode.IMMEDIATE));
5050
var isInstallImmediate = (remotePackage && remotePackage.isMandatory) ? mandatoryUpdateIsImmediate : regularUpdateIsImmediate;
51-
51+
5252
return CodePush.sync(options)
5353
.then((status) => {
5454
if (!(isInstallImmediate && status === CodePush.SyncStatus.UPDATE_INSTALLED)) {
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
var CodePushWrapper = require("../codePushWrapper.js");
22

33
module.exports = {
4-
startTest: function(testApp) {
4+
startTest: function (testApp) {
55
CodePushWrapper.checkForUpdate(testApp);
66
},
7-
8-
getScenarioName: function() {
7+
8+
getScenarioName: function () {
99
return "Check for Update";
1010
}
11-
};
11+
};
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
var CodePushWrapper = require("../codePushWrapper.js");
22

33
module.exports = {
4-
startTest: function(testApp) {
4+
startTest: function (testApp) {
55
CodePushWrapper.checkForUpdate(testApp, undefined, undefined, "CUSTOM-DEPLOYMENT-KEY");
66
},
7-
8-
getScenarioName: function() {
7+
8+
getScenarioName: function () {
99
return "Check for Update Custom Key";
1010
}
1111
};
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var CodePushWrapper = require("../codePushWrapper.js");
22

33
module.exports = {
4-
startTest: function(testApp) {
4+
startTest: function (testApp) {
55
CodePushWrapper.checkForUpdate(testApp,
66
CodePushWrapper.download.bind(undefined, testApp, undefined, undefined));
77
},
8-
9-
getScenarioName: function() {
8+
9+
getScenarioName: function () {
1010
return "Download Update";
1111
}
1212
};

test/template/scenarios/scenarioInstall.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.checkAndInstall(testApp, undefined, undefined, CodePush.InstallMode.IMMEDIATE);
77
},
8-
9-
getScenarioName: function() {
8+
9+
getScenarioName: function () {
1010
return "Install";
1111
}
1212
};

test/template/scenarios/scenarioInstallOnRestartWithRevert.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.checkAndInstall(testApp, undefined, undefined, CodePush.InstallMode.ON_NEXT_RESTART);
77
},
8-
9-
getScenarioName: function() {
8+
9+
getScenarioName: function () {
1010
return "Install on Restart with Revert";
1111
}
1212
};

test/template/scenarios/scenarioInstallOnResumeWithRevert.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.checkAndInstall(testApp, undefined, undefined, CodePush.InstallMode.ON_NEXT_RESUME);
77
},
8-
9-
getScenarioName: function() {
8+
9+
getScenarioName: function () {
1010
return "Install on Resume with Revert";
1111
}
1212
};

test/template/scenarios/scenarioInstallRestart2x.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
6-
CodePushWrapper.checkAndInstall(testApp,
5+
startTest: function (testApp) {
6+
CodePushWrapper.checkAndInstall(testApp,
77
() => {
88
CodePush.restartApp();
99
CodePush.restartApp();
1010
}
1111
);
1212
},
13-
14-
getScenarioName: function() {
13+
14+
getScenarioName: function () {
1515
return "Install and Restart 2x";
1616
}
1717
};

test/template/scenarios/scenarioInstallWithRevert.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.checkAndInstall(testApp, undefined, undefined, CodePush.InstallMode.IMMEDIATE);
77
},
8-
9-
getScenarioName: function() {
8+
9+
getScenarioName: function () {
1010
return "Install with Revert";
1111
}
1212
};

test/template/scenarios/scenarioRestart.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
testApp.sendCurrentAndPendingPackage()
77
.then(() => {
88
CodePushWrapper.sync(testApp, (status) => {
@@ -12,8 +12,8 @@ module.exports = {
1212
}, undefined, { installMode: CodePush.InstallMode.ON_NEXT_RESTART });
1313
});
1414
},
15-
16-
getScenarioName: function() {
15+
16+
getScenarioName: function () {
1717
return "Restart";
1818
}
1919
};

test/template/scenarios/scenarioRestart2x.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePush.restartApp(true);
7-
CodePushWrapper.checkAndInstall(testApp,
7+
CodePushWrapper.checkAndInstall(testApp,
88
() => {
99
CodePush.restartApp(true);
1010
}
1111
);
1212
},
13-
14-
getScenarioName: function() {
13+
14+
getScenarioName: function () {
1515
return "Restart2x";
1616
}
1717
};

test/template/scenarios/scenarioSync.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.sync(testApp, undefined, undefined, { installMode: CodePush.InstallMode.IMMEDIATE });
77
},
8-
9-
getScenarioName: function() {
8+
9+
getScenarioName: function () {
1010
return "Sync";
1111
}
1212
};

test/template/scenarios/scenarioSync2x.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.sync(testApp, undefined, undefined, { installMode: CodePush.InstallMode.IMMEDIATE });
77
CodePushWrapper.sync(testApp, undefined, undefined, { installMode: CodePush.InstallMode.IMMEDIATE });
88
},
9-
10-
getScenarioName: function() {
9+
10+
getScenarioName: function () {
1111
return "Sync 2x";
1212
}
1313
};

test/template/scenarios/scenarioSyncMandatoryDefault.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.sync(testApp, undefined, undefined, { installMode: CodePush.InstallMode.ON_NEXT_RESTART });
77
},
8-
9-
getScenarioName: function() {
8+
9+
getScenarioName: function () {
1010
return "Sync Mandatory Default";
1111
}
1212
};

test/template/scenarios/scenarioSyncMandatoryRestart.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ var CodePushWrapper = require("../codePushWrapper.js");
22
import CodePush from "react-native-code-push";
33

44
module.exports = {
5-
startTest: function(testApp) {
5+
startTest: function (testApp) {
66
CodePushWrapper.sync(testApp, undefined, undefined,
7-
{ installMode: CodePush.InstallMode.IMMEDIATE,
8-
mandatoryInstallMode: CodePush.InstallMode.ON_NEXT_RESTART });
7+
{
8+
installMode: CodePush.InstallMode.IMMEDIATE,
9+
mandatoryInstallMode: CodePush.InstallMode.ON_NEXT_RESTART
10+
});
911
},
10-
11-
getScenarioName: function() {
12+
13+
getScenarioName: function () {
1214
return "Sync Mandatory Restart";
1315
}
1416
};

0 commit comments

Comments
 (0)