mailtrain/test/e2e/lib/semaphore.js
Tomas Bures bb2b3da9dd Added waitUntilVisibleAfterRefresh and textsToWaitFor - both discussed with @witzig.
Page objects refactored to exploit textsToWaitFor if relevant.

Login tests refactored for the newer API.

Some additional tests in subscription. The rest at least included as "pending".
2017-05-26 00:13:40 +02:00

35 lines
No EOL
624 B
JavaScript

'use strict';
const Promise = require('bluebird');
class Semaphore {
constructor() {
this.counter = 0;
}
enter() {
this.counter++;
}
exit() {
this.counter--;
}
async waitForEmpty() {
const self = this;
function wait(resolve) {
if (self.counter == 0) {
resolve();
} else {
setTimeout(wait, 500, resolve);
}
}
return new Promise(resolve => {
setTimeout(wait, 500, resolve);
})
}
}
module.exports = Semaphore;