Change the Server tests to be compatible with electron server

This commit is contained in:
Adomas Venčkauskas 2018-08-20 15:15:59 +03:00
parent 29fe62e0a7
commit 57fd05c7e3
2 changed files with 6 additions and 6 deletions

View file

@ -43,7 +43,7 @@ Zotero.Server = new function() {
/** /**
* initializes a very rudimentary web server * initializes a very rudimentary web server
*/ */
this.init = function(port, bindAllAddr, maxConcurrentConnections) { this.init = async function(port, bindAllAddr, maxConcurrentConnections) {
if (Zotero.HTTP.browserIsOffline()) { if (Zotero.HTTP.browserIsOffline()) {
Zotero.debug('Browser is offline -- not initializing HTTP server'); Zotero.debug('Browser is offline -- not initializing HTTP server');
_registerOnlineObserver(); _registerOnlineObserver();

View file

@ -4,9 +4,9 @@ describe("Zotero.Server", function () {
Components.utils.import("resource://zotero-unit/httpd.js"); Components.utils.import("resource://zotero-unit/httpd.js");
var serverPath; var serverPath;
before(function* () { before(async function () {
Zotero.Prefs.set("httpServer.enabled", true); Zotero.Prefs.set("httpServer.enabled", true);
Zotero.Server.init(); await Zotero.Server.init();
serverPath = 'http://127.0.0.1:' + Zotero.Prefs.get('httpServer.port'); serverPath = 'http://127.0.0.1:' + Zotero.Prefs.get('httpServer.port');
}); });
@ -25,7 +25,7 @@ describe("Zotero.Server", function () {
init: function (options) { init: function (options) {
called = true; called = true;
assert.isObject(options); assert.isObject(options);
assert.propertyVal(options.headers, "Accept-Charset", "UTF-8"); assert.equal(options.headers["Accept-Charset"], "UTF-8");
return 204; return 204;
} }
}; };
@ -77,7 +77,7 @@ describe("Zotero.Server", function () {
assert.ok(called); assert.ok(called);
assert.equal(req.status, 201); assert.equal(req.status, 201);
assert.equal(req.getResponseHeader("Content-Type"), "text/plain"); assert.include(req.getResponseHeader("Content-Type"), "text/plain");
assert.equal(req.responseText, "Test"); assert.equal(req.responseText, "Test");
}); });
@ -137,7 +137,7 @@ describe("Zotero.Server", function () {
assert.ok(called); assert.ok(called);
assert.equal(req.status, 201); assert.equal(req.status, 201);
assert.equal(req.getResponseHeader("Content-Type"), "text/plain"); assert.include(req.getResponseHeader("Content-Type"), "text/plain");
assert.equal(req.responseText, "Test"); assert.equal(req.responseText, "Test");
}); });
}); });