specify("error when passed non-function", function() { return Promise.resolve(3) .spread() .then(assert.fail) .caught(Promise.TypeError, function() {}); });
it("works with a failing resource", async () => { const d = rejectedDisposer(3); let called = false; const v = await (Promise.using(d, assert.fail).catch(e => { assert.equal(e, 3); called = true; })); assert(called); });
describe("bluebird schedule tests", () => { it("should throw for non function", function() { try { Promise.setScheduler({}); } catch (e) { return; } assert.fail(); }); after(() => Promise.setScheduler.disable()); })
it("works with two succeeding resources and one failing resource", async () => { const [d, e, f] = [disposer(), rejectedDisposer(3), disposer()]; assert(!d._obj.closed); assert(!f._obj.closed); await Promise.using(d, e, f, assert.fail).catch(e => { assert.equal(e, 3); }); assert(d._obj.closed); assert(f._obj.closed); });
it("works with one succeeding resource and one failing promise", async () => { const [d, e] = [disposer(), Promise.reject(3)]; assert(!d._obj.closed); await Promise.using(d, e, assert.fail).catch(e => { assert.equal(e, 3); }); assert(d._obj.closed); });
it("propagates error", function() { var a = [promised(1), promised(2), promised(3)]; var e = new Error("asd"); return Promise.reduce(a, function(total, a) { if (a > 2) { throw e; } return total + a + 5; }, 0).then(assert.fail, function(err) { assert.equal(err, e); }); });
function returnThenableReject(thenable, expected) { const promise = Promise.resolve(true) return promise.thenReturn(thenable).then(assert.fail, function(v){ assert(v === expected); }); }
it("works with one succeeding promise and one failing resource", async () => { const [d, e] = [Promise.resolve(), rejectedDisposer(3)]; await Promise.using(d, e, assert.fail).catch(e => { assert.equal(e, 3); }); });
describe("Spawn", function() { it("should work", function() { return Promise.spawn(function*() { return yield Promise.resolve(1); }).then(function(value) { assert.strictEqual(value, 1); }); }); it("should return rejected promise when passed non function", function() { return Promise.spawn({}).then(assert.fail, function(err) { assert(err instanceof Promise.TypeError); }); }); });
describe("OperationalError -- bb test - divergence!", function() { it("should not work without new", function() { try { var a = Promise.OperationalError("msg"); } catch (e) {} if(a) assert.fail(); }); it("should work with new", function() { var a = new Promise.OperationalError("msg"); assert.strictEqual(a.message, "msg"); assert(a instanceof Error); }); });
specify("getTabErroneous", function() { return chrome.getTabErroneousAsync(2).then(assert.fail, function(e) { assert.equal(e, err); }); });
describe("thenReturn", function () { it("forwards errors", () => { return Promise.reject(10) .thenReturn(100) .then(assert.fail, assert.ok); }); });
it("works with one succeeding resource and one failing resource", async () => { const [d, e] = [disposer(), rejectedDisposer(3)]; assert(!d._obj.closed); await Promise.using(d, e, assert.fail).catch(e => { assert.equal(e, 3); }); assert(d._obj.closed); });
specify("error when resolution is non-spredable", function() { return Promise.resolve(3) .spread(function(){}) .then(assert.fail) .caught(Promise.TypeError, function() {}); });