Run notifier observers in tests after all others
This ensures that main functionality will have already run if a test waits on the same event.
This commit is contained in:
parent
e807f98e02
commit
502f5fe491
2 changed files with 5 additions and 3 deletions
|
@ -236,7 +236,7 @@ Zotero.Notifier = new function(){
|
|||
|
||||
/**
|
||||
* Get order of observer by priority, with lower numbers having higher priority.
|
||||
* If an observer doesn't have a priority, sort it last.
|
||||
* If an observer doesn't have a priority, default to 100.
|
||||
*/
|
||||
function _getObserverOrder(type) {
|
||||
var order = [];
|
||||
|
@ -247,7 +247,7 @@ Zotero.Notifier = new function(){
|
|||
}
|
||||
order.push({
|
||||
id: i,
|
||||
priority: _observers[i].priority || false
|
||||
priority: _observers[i].priority || 100
|
||||
});
|
||||
}
|
||||
order.sort((a, b) => {
|
||||
|
|
|
@ -249,6 +249,8 @@ function waitForItemEvent(event) {
|
|||
|
||||
/**
|
||||
* Wait for a single notifier event and return a promise for the data
|
||||
*
|
||||
* Tests run after all other handlers (priority 101, since handlers are 100 by default)
|
||||
*/
|
||||
function waitForNotifierEvent(event, type) {
|
||||
if (!event) throw new Error("event not provided");
|
||||
|
@ -262,7 +264,7 @@ function waitForNotifierEvent(event, type) {
|
|||
extraData: extraData
|
||||
});
|
||||
}
|
||||
}}, [type]);
|
||||
}}, [type], 'test', 101);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue