-
Notifications
You must be signed in to change notification settings - Fork 1
/
Buzy.test.js
31 lines (29 loc) · 735 Bytes
/
Buzy.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Created by adithya.s on 23/09/17.
*/
const Buzy = require('./Buzy');
const b = new Buzy([function (message) {
console.log('in b', message);
}]);
const c = new Buzy([function (message) {
console.log('in c', message, c.isBusy())
}], [b]);
b.addPromise(new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('yo1');
}, 1000);
}));
setTimeout(function () {
b.addPromise(new Promise(function (resolve, reject) {
setTimeout(function () {
reject('yo2');
}, 500);
}));
}, 100);
setTimeout(function () {
b.addPromise(new Promise(function (resolve, reject) {
setTimeout(function () {
reject('yo3');
}, 10);
}));
}, 500);