mirror of
https://github.com/apache/cordova-plugin-file-transfer.git
synced 2026-04-28 00:02:49 +08:00
CB-11926 Tests can use local server
This commit is contained in:
+27
-3
@@ -42,11 +42,14 @@ exports.defineAutoTests = function () {
|
||||
var DATA_URI_CONTENT = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
||||
var DATA_URI_CONTENT_LENGTH = 85; // bytes. (This is the raw file size: used https://en.wikipedia.org/wiki/File:Red-dot-5px.png from https://en.wikipedia.org/wiki/Data_URI_scheme)
|
||||
|
||||
// config for upload test server
|
||||
// upload test server address
|
||||
// NOTE:
|
||||
// more info at https://github.com/apache/cordova-labs/tree/cordova-filetransfer
|
||||
var SERVER = "http://cordova-vm.apache.org:5000";
|
||||
var SERVER_WITH_CREDENTIALS = "http://cordova_user:cordova_password@cordova-vm.apache.org:5000";
|
||||
// Will get it from the config
|
||||
// you can specify it as a 'FILETRANSFER_SERVER_ADDRESS' variable upon test plugin installation
|
||||
// or change the default value in plugin.xml
|
||||
var SERVER = "";
|
||||
var SERVER_WITH_CREDENTIALS = "";
|
||||
|
||||
// flags
|
||||
var isWindows = cordova.platformId === "windows8" || cordova.platformId === "windows";
|
||||
@@ -202,6 +205,11 @@ exports.defineAutoTests = function () {
|
||||
}
|
||||
};
|
||||
|
||||
var setServerAddress = function (address) {
|
||||
SERVER = address;
|
||||
SERVER_WITH_CREDENTIALS = SERVER.replace('http://', 'http://cordova_user:cordova_password@');
|
||||
};
|
||||
|
||||
// NOTE:
|
||||
// there are several beforeEach calls, one per async call; since calling done()
|
||||
// signifies a completed async call, each async call needs its own done(), and
|
||||
@@ -266,6 +274,22 @@ exports.defineAutoTests = function () {
|
||||
}
|
||||
});
|
||||
|
||||
it ("util spec: get file transfer server url", function () {
|
||||
try {
|
||||
// attempt to synchronously load medic config
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "../fileTransferOpts.json", false);
|
||||
xhr.send(null);
|
||||
var parsedCfg = JSON.parse(xhr.responseText);
|
||||
if (parsedCfg.serverAddress) {
|
||||
setServerAddress(parsedCfg.serverAddress);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error('Unable to load file transfer server url: ' + ex);
|
||||
fail(ex);
|
||||
}
|
||||
});
|
||||
|
||||
it("should initialise correctly", function() {
|
||||
expect(this.persistentRoot).toBeDefined();
|
||||
expect(this.tempRoot).toBeDefined();
|
||||
|
||||
Reference in New Issue
Block a user