Q -> Bluebird in tests

This commit is contained in:
Dan Stillman 2015-04-13 03:27:51 -04:00
parent a91151756b
commit 6dfdae870e
3 changed files with 8 additions and 9 deletions

View file

@ -1,6 +1,5 @@
Components.utils.import("resource://gre/modules/FileUtils.jsm"); Components.utils.import("resource://gre/modules/FileUtils.jsm");
Components.utils.import("resource://gre/modules/osfile.jsm"); Components.utils.import("resource://gre/modules/osfile.jsm");
Components.utils.import("resource://zotero/q.js");
var EventUtils = Components.utils.import("resource://zotero-unit/EventUtils.jsm"); var EventUtils = Components.utils.import("resource://zotero-unit/EventUtils.jsm");
var ZoteroUnit = Components.classes["@mozilla.org/commandlinehandler/general-startup;1?type=zotero-unit"]. var ZoteroUnit = Components.classes["@mozilla.org/commandlinehandler/general-startup;1?type=zotero-unit"].
@ -110,6 +109,6 @@ if(run) {
window.onload = function() { window.onload = function() {
Zotero.Schema.schemaUpdatePromise.then(function() { Zotero.Schema.schemaUpdatePromise.then(function() {
mocha.run(); mocha.run();
}).done(); });
}; };
} }

View file

@ -3,7 +3,7 @@
* resolved with the event. * resolved with the event.
*/ */
function waitForDOMEvent(target, event, capture) { function waitForDOMEvent(target, event, capture) {
var deferred = Q.defer(); var deferred = Zotero.Promise.defer();
var func = function(ev) { var func = function(ev) {
target.removeEventListener("event", func, capture); target.removeEventListener("event", func, capture);
deferred.resolve(ev); deferred.resolve(ev);
@ -32,7 +32,7 @@ function loadZoteroPane() {
// Hack to wait for pane load to finish. This is the same hack // Hack to wait for pane load to finish. This is the same hack
// we use in ZoteroPane.js, so either it's not good enough // we use in ZoteroPane.js, so either it's not good enough
// there or it should be good enough here. // there or it should be good enough here.
return Q.delay(52).then(function() { return Zotero.Promise.delay(52).then(function() {
return win; return win;
}); });
}); });
@ -42,7 +42,7 @@ function loadZoteroPane() {
* Waits for a window with a specific URL to open. Returns a promise for the window. * Waits for a window with a specific URL to open. Returns a promise for the window.
*/ */
function waitForWindow(uri) { function waitForWindow(uri) {
var deferred = Q.defer(); var deferred = Zotero.Promise.defer();
Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Services.jsm");
var loadobserver = function(ev) { var loadobserver = function(ev) {
ev.originalTarget.removeEventListener("load", loadobserver, false); ev.originalTarget.removeEventListener("load", loadobserver, false);
@ -65,7 +65,7 @@ function waitForWindow(uri) {
* Waits for a single item event. Returns a promise for the item ID(s). * Waits for a single item event. Returns a promise for the item ID(s).
*/ */
function waitForItemEvent(event) { function waitForItemEvent(event) {
var deferred = Q.defer(); var deferred = Zotero.Promise.defer();
var notifierID = Zotero.Notifier.registerObserver({notify:function(ev, type, ids, extraData) { var notifierID = Zotero.Notifier.registerObserver({notify:function(ev, type, ids, extraData) {
if(ev == event) { if(ev == event) {
Zotero.Notifier.unregisterObserver(notifierID); Zotero.Notifier.unregisterObserver(notifierID);
@ -97,7 +97,7 @@ function getWindows(uri) {
* should assume failure. * should assume failure.
*/ */
function waitForCallback(cb, interval, timeout) { function waitForCallback(cb, interval, timeout) {
var deferred = Q.defer(); var deferred = Zotero.Promise.defer();
if(interval === undefined) interval = 100; if(interval === undefined) interval = 100;
if(timeout === undefined) timeout = 10000; if(timeout === undefined) timeout = 10000;
var start = Date.now(); var start = Date.now();
@ -120,7 +120,7 @@ function waitForCallback(cb, interval, timeout) {
*/ */
function installPDFTools() { function installPDFTools() {
if(Zotero.Fulltext.pdfConverterIsRegistered() && Zotero.Fulltext.pdfInfoIsRegistered()) { if(Zotero.Fulltext.pdfConverterIsRegistered() && Zotero.Fulltext.pdfInfoIsRegistered()) {
return Q(true); return Zotero.Promise.resolve(true);
} }
// Begin install procedure // Begin install procedure

View file

@ -6,7 +6,7 @@ describe("PDF Recognition", function() {
this.timeout(60000); this.timeout(60000);
// Load Zotero pane, install PDF tools, and load the // Load Zotero pane, install PDF tools, and load the
// translators // translators
return Q.all([loadZoteroPane().then(function(w) { return Zotero.Promise.all([loadZoteroPane().then(function(w) {
win = w; win = w;
}), installPDFTools()]); }), installPDFTools()]);
}); });