31MS

MS

7

Suites

12

Tests

11

Passed

1

Failed

0

Pending

0% Pending
91.7% Passing

The addCard function

/tests/unit/lib/add-card.js
  • 3 ms
  • 1
  • 1
  • 0
  • 0

Tests

should return a promise

3 ms
var ctx = {
                            stripe: {customers: {
                                createSource: R.always(BPromise.resolve())
                            }},
                            user: {stripeCustomer: {}}
                        };
                        return addCard.call(ctx).should.be.Promise;

The promise returned by the addCard function

/tests/unit/lib/add-card.js
  • 5 ms
  • 2
  • 2
  • 0
  • 0

Tests

should be resolved if adding the card succeeds

3 ms
var ctx = {
                            stripe: {customers: {
                                createSource: R.always(BPromise.resolve({}))
                            }},
                            user: {stripeCustomer: {}}
                        };
                        return addCard.call(ctx).should.be.fulfilledWith({});

should be rejected if adding the card fails

2 ms
var ctx = {
                            stripe: {customers: {
                                createSource: function () {
                                    return BPromise.reject();
                                }
                            }},
                            user: {stripeCustomer: {}}
                        };
                        return addCard.call(ctx).should.be.rejectedWith("Error while adding the card.");

The deleteCard function

/tests/unit/lib/delete-card.js
  • 0 ms
  • 1
  • 1
  • 0
  • 0

Tests

should return a promise

0 ms
var ctx = {
                            stripe: {customers: {
                                deleteCard: R.always(BPromise.resolve())
                            }},
                            user: {stripeCustomer: {}}
                        };
                        return deleteCard.call(ctx).should.be.Promise;

The promise returned by the deleteCard function

/tests/unit/lib/delete-card.js
  • 1 ms
  • 2
  • 2
  • 0
  • 0

Tests

should be resolved if deleting the card succeeds

1 ms
var ctx = {
                            stripe: {customers: {
                                deleteCard: R.always(BPromise.resolve({}))
                            }},
                            user: {stripeCustomer: {}}
                        };
                        return deleteCard.call(ctx).should.be.fulfilledWith({});

should be rejected if deleting the card fails

0 ms
var ctx = {
                            stripe: {customers: {
                                deleteCard: function () {
                                    return BPromise.reject();
                                }
                            }},
                            user: {stripeCustomer: {}}
                        };
                        return deleteCard.call(ctx).should.be.rejectedWith("Error while deleting the card.");

The ensureLogin function

/tests/unit/lib/ensure-login.js
  • 1 ms
  • 2
  • 2
  • 0
  • 0

Tests

should throw if userId in the context is null

1 ms
var ctx = {
                            userId: null
                        };
                        return ensureLogin.bind(ctx).should.throw("Login required.");

should not throw if userId in the context is defined

0 ms
var ctx = {
                            userId: "someId"
                        };
                        return ensureLogin.bind(ctx).should.not.throw();

The stripeCustomerSync function

/tests/unit/lib/stripe-costumer-sync.js
  • 1 ms
  • 1
  • 1
  • 0
  • 0

Tests

should return a promise

1 ms
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;

The promise returned by the stripeCustomerSync function

/tests/unit/lib/stripe-costumer-sync.js
  • 2 ms
  • 3
  • 2
  • 1
  • 0

Tests

should be resolved if syncing succeeds

1 ms

AssertionError: expected [Promise] to be fulfilled

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

should be rejected if syncing fails at stripe

1 ms
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.");

should be rejected if syncing fails at mongo

0 ms
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.");