var ctx = {
stripe: {customers: {
createSource: R.always(BPromise.resolve())
}},
user: {stripeCustomer: {}}
};
return addCard.call(ctx).should.be.Promise;
var ctx = {
stripe: {customers: {
createSource: R.always(BPromise.resolve({}))
}},
user: {stripeCustomer: {}}
};
return addCard.call(ctx).should.be.fulfilledWith({});
var ctx = {
stripe: {customers: {
createSource: function () {
return BPromise.reject();
}
}},
user: {stripeCustomer: {}}
};
return addCard.call(ctx).should.be.rejectedWith("Error while adding the card.");
var ctx = {
stripe: {customers: {
deleteCard: R.always(BPromise.resolve())
}},
user: {stripeCustomer: {}}
};
return deleteCard.call(ctx).should.be.Promise;
var ctx = {
stripe: {customers: {
deleteCard: R.always(BPromise.resolve({}))
}},
user: {stripeCustomer: {}}
};
return deleteCard.call(ctx).should.be.fulfilledWith({});
var ctx = {
stripe: {customers: {
deleteCard: function () {
return BPromise.reject();
}
}},
user: {stripeCustomer: {}}
};
return deleteCard.call(ctx).should.be.rejectedWith("Error while deleting the card.");
var ctx = {
userId: null
};
return ensureLogin.bind(ctx).should.throw("Login required.");
var ctx = {
userId: "someId"
};
return ensureLogin.bind(ctx).should.not.throw();
var ctx = {
stripe: {customers: {
retrieve: R.always(BPromise.resolve())
}},
db: {collection: R.always({
update: function (first, second, cb) {
cb(false, {});
}
})},
user: {stripeCustomer: {}}
};
return stripeCustomerSync.call(ctx).should.be.Promise;
var ctx = {
stripe: {customers: {
retrieve: R.always(BPromise.resolve())
}},
db: {collection: R.always({
update: function (first, second, cb) {
cb(null, {});
}
})},
user: {stripeCustomer: {}}
};
return stripeCustomerSync.call(ctx).should.be.fulfilledWith({});
AssertionError: expected [Promise] to be fulfilled
var ctx = {
stripe: {customers: {
retrieve: function () {
return BPromise.reject();
}
}},
db: {collection: R.always({
update: function (first, second, cb) {
cb(null, {});
}
})},
user: {stripeCustomer: {}}
};
return stripeCustomerSync.call(ctx).should.be.rejectedWith("Error syncing with stripe. Try again.");
var ctx = {
stripe: {customers: {
retrieve: R.always(BPromise.resolve())
}},
db: {collection: R.always({
update: function (first, second, cb) {
cb(true);
}
})},
user: {stripeCustomer: {}}
};
return stripeCustomerSync.call(ctx).should.be.rejectedWith("Error syncing with stripe. Try again.");