diff --git a/package-lock.json b/package-lock.json index 0d4cd0b971..0cea35de7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10203,6 +10203,12 @@ "promise": "6.1.0" } }, + "just-extend": { + "version": "1.1.27", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", + "dev": true + }, "kareem": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/kareem/-/kareem-1.2.1.tgz", @@ -12573,6 +12579,51 @@ } } }, + "nise": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.2.2.tgz", + "integrity": "sha512-rvxf+PSZeCKtP0DgmwMmNf1G3I6X1r4WHiP2H88PlIkOkt7mGqufdokjS8caoHBgZzVx0ee/5ytGcGHbZaUw8w==", + "dev": true, + "requires": { + "formatio": "1.2.0", + "just-extend": "1.1.27", + "lolex": "1.6.0", + "path-to-regexp": "1.7.0", + "text-encoding": "0.6.4" + }, + "dependencies": { + "formatio": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.2.0.tgz", + "integrity": "sha1-87IWfZBoxGmKjVH092CjmlTYGOs=", + "dev": true, + "requires": { + "samsam": "1.1.2" + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "lolex": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.6.0.tgz", + "integrity": "sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY=", + "dev": true + }, + "path-to-regexp": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", + "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "dev": true, + "requires": { + "isarray": "0.0.1" + } + } + } + }, "no-case": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", @@ -16552,15 +16603,56 @@ "integrity": "sha1-BcLuxXn//+FFoDCsJs/qYbmA+r4=" }, "sinon": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", - "integrity": "sha1-RUKk9JugxFwF6y6d2dID4rjv4L8=", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.2.2.tgz", + "integrity": "sha512-BEa593xl+IkIc94nKo0O0LauQC/gQy8Gyv4DkzPwF/9DweC5phr1y+42zibCpn9abfkdHxt9r8AhD0R6u9DE/Q==", "dev": true, "requires": { - "formatio": "1.1.1", - "lolex": "1.3.2", - "samsam": "1.1.2", - "util": "0.10.3" + "diff": "3.2.0", + "formatio": "1.2.0", + "lodash.get": "4.4.2", + "lolex": "2.3.2", + "nise": "1.2.2", + "supports-color": "5.1.0", + "type-detect": "4.0.7" + }, + "dependencies": { + "formatio": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.2.0.tgz", + "integrity": "sha1-87IWfZBoxGmKjVH092CjmlTYGOs=", + "dev": true, + "requires": { + "samsam": "1.1.2" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "lolex": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", + "dev": true + }, + "supports-color": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.1.0.tgz", + "integrity": "sha512-Ry0AwkoKjDpVKK4sV4h6o3UJmNRbjYm2uXhwfj3J56lMVdvnUNqzQVRztOOMGQ++w1K/TjNDFvpJk0F/LoeBCQ==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + }, + "type-detect": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.7.tgz", + "integrity": "sha512-4Rh17pAMVdMWzktddFhISRnUnFIStObtUMNGzDwlA6w/77bmGv3aBbRdCmQR6IjzfkTo9otnW+2K/cDRhKSxDA==", + "dev": true + } } }, "sinon-chai": { @@ -17868,6 +17960,12 @@ } } }, + "text-encoding": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", + "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=", + "dev": true + }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", diff --git a/package.json b/package.json index 01ebf6a7cf..17460cc059 100644 --- a/package.json +++ b/package.json @@ -186,7 +186,7 @@ "phantomjs-prebuilt": "^2.1.12", "require-again": "^2.0.0", "selenium-server": "^3.0.1", - "sinon": "^1.17.2", + "sinon": "^4.2.2", "sinon-chai": "^2.8.0", "sinon-stub-promise": "^4.0.0", "webpack-bundle-analyzer": "^2.2.1", diff --git a/test/api/v3/unit/libs/payments.test.js b/test/api/v3/unit/libs/payments.test.js index 7cb136698d..f3e03758db 100644 --- a/test/api/v3/unit/libs/payments.test.js +++ b/test/api/v3/unit/libs/payments.test.js @@ -417,6 +417,7 @@ describe('payments/index', () => { it('awards mystery items when within the timeframe for a mystery item', async () => { let mayMysteryItemTimeframe = 1464725113000; // May 31st 2016 let fakeClock = sinon.useFakeTimers(mayMysteryItemTimeframe); + data = { paymentMethod: 'PaymentMethod', user, sub: { key: 'basic_3mo' } }; await api.createSubscription(data); diff --git a/test/api/v3/unit/libs/payments/amazon/upgrade-groupplan.test.js b/test/api/v3/unit/libs/payments/amazon/upgrade-groupplan.test.js index a62e7f1b53..e60516e49c 100644 --- a/test/api/v3/unit/libs/payments/amazon/upgrade-groupplan.test.js +++ b/test/api/v3/unit/libs/payments/amazon/upgrade-groupplan.test.js @@ -47,7 +47,7 @@ describe('#upgradeGroupPlan', () => { }); afterEach(function () { - sinon.restore(amzLib.authorizeOnBillingAgreement); + amzLib.authorizeOnBillingAgreement.restore(); uuid.v4.restore(); }); diff --git a/test/api/v3/unit/libs/payments/paypal/subscribe.test.js b/test/api/v3/unit/libs/payments/paypal/subscribe.test.js index f0450ccfc1..ee1ccd3938 100644 --- a/test/api/v3/unit/libs/payments/paypal/subscribe.test.js +++ b/test/api/v3/unit/libs/payments/paypal/subscribe.test.js @@ -58,7 +58,7 @@ describe('subscribe', () => { cc.validate.restore(); }); - it('subscribes with amazon with a coupon', async () => { + it('subscribes with paypal with a coupon', async () => { sub.discount = 40; sub.key = 'google_6mo'; coupon = 'example-coupon'; diff --git a/test/api/v3/unit/libs/payments/stripe/checkout-subscription.test.js b/test/api/v3/unit/libs/payments/stripe/checkout-subscription.test.js index 0c2683b8c2..d1d908c7fa 100644 --- a/test/api/v3/unit/libs/payments/stripe/checkout-subscription.test.js +++ b/test/api/v3/unit/libs/payments/stripe/checkout-subscription.test.js @@ -73,7 +73,7 @@ describe('checkout with subscription', () => { }); afterEach(function () { - sinon.restore(stripe.subscriptions.update); + stripe.subscriptions.update.restore(); stripe.customers.create.restore(); payments.createSubscription.restore(); }); @@ -144,7 +144,7 @@ describe('checkout with subscription', () => { cc.validate.restore(); }); - it('subscribes with amazon with a coupon', async () => { + it('subscribes with stripe with a coupon', async () => { sub.discount = 40; sub.key = 'google_6mo'; coupon = 'example-coupon'; diff --git a/test/api/v3/unit/libs/payments/stripe/handle-webhook.test.js b/test/api/v3/unit/libs/payments/stripe/handle-webhook.test.js index c91cb7e919..762e840c8a 100644 --- a/test/api/v3/unit/libs/payments/stripe/handle-webhook.test.js +++ b/test/api/v3/unit/libs/payments/stripe/handle-webhook.test.js @@ -35,7 +35,10 @@ describe('Stripe - Webhooks', () => { const error = new Error(`Missing handler for Stripe webhook ${eventType}`); await stripePayments.handleWebhooks({requestBody: event}, stripe); expect(logger.error).to.have.been.called.once; - expect(logger.error).to.have.been.calledWith(error, {event: eventRetrieved}); + + const calledWith = logger.error.getCall(0).args; + expect(calledWith[0].message).to.equal(error.message); + expect(calledWith[1].event).to.equal(eventRetrieved); }); it('retrieves and validates the event from Stripe', async () => { diff --git a/test/api/v3/unit/libs/payments/stripe/upgrade-group-plan.test.js b/test/api/v3/unit/libs/payments/stripe/upgrade-group-plan.test.js index f0126631a9..6461209cb7 100644 --- a/test/api/v3/unit/libs/payments/stripe/upgrade-group-plan.test.js +++ b/test/api/v3/unit/libs/payments/stripe/upgrade-group-plan.test.js @@ -45,7 +45,7 @@ describe('Stripe - Upgrade Group Plan', () => { }); afterEach(function () { - sinon.restore(stripe.subscriptions.update); + stripe.subscriptions.update.restore(); }); it('updates a group plan quantity', async () => { diff --git a/test/api/v3/unit/libs/preening.test.js b/test/api/v3/unit/libs/preening.test.js index 3c28557125..a6ffef1e70 100644 --- a/test/api/v3/unit/libs/preening.test.js +++ b/test/api/v3/unit/libs/preening.test.js @@ -8,7 +8,10 @@ describe('preenHistory', () => { beforeEach(() => { // Replace system clocks so we can get predictable results - clock = sinon.useFakeTimers(Number(moment('2013-10-20').zone(0).startOf('day').toDate()), 'Date'); + clock = sinon.useFakeTimers({ + now: Number(moment('2013-10-20').zone(0).startOf('day').toDate()), + toFake: ['Date'], + }); }); afterEach(() => { return clock.restore(); diff --git a/test/api/v3/unit/libs/pushNotifications.js b/test/api/v3/unit/libs/pushNotifications.js index ee877d517f..f033d958ff 100644 --- a/test/api/v3/unit/libs/pushNotifications.js +++ b/test/api/v3/unit/libs/pushNotifications.js @@ -22,7 +22,7 @@ describe('pushNotifications', () => { sandbox.stub(nconf, 'get').returns('true-key'); - sandbox.stub(gcmLib.Sender.prototype, 'send', fcmSendSpy); + sandbox.stub(gcmLib.Sender.prototype, 'send').callsFake(fcmSendSpy); sandbox.stub(pushNotify, 'apn').returns({ on: () => null, diff --git a/test/api/v3/unit/middlewares/ensureAccessRight.test.js b/test/api/v3/unit/middlewares/ensureAccessRight.test.js index 4421b82a3e..0adee75fd4 100644 --- a/test/api/v3/unit/middlewares/ensureAccessRight.test.js +++ b/test/api/v3/unit/middlewares/ensureAccessRight.test.js @@ -24,7 +24,9 @@ describe('ensure access middlewares', () => { ensureAdmin(req, res, next); - expect(next).to.be.calledWith(new NotAuthorized(i18n.t('noAdminAccess'))); + const calledWith = next.getCall(0).args; + expect(calledWith[0].message).to.equal(i18n.t('noAdminAccess')); + expect(calledWith[0] instanceof NotAuthorized).to.equal(true); }); it('passes when user is an admin', () => { @@ -43,7 +45,9 @@ describe('ensure access middlewares', () => { ensureSudo(req, res, next); - expect(next).to.be.calledWith(new NotAuthorized(apiMessages('noSudoAccess'))); + const calledWith = next.getCall(0).args; + expect(calledWith[0].message).to.equal(apiMessages('noSudoAccess')); + expect(calledWith[0] instanceof NotAuthorized).to.equal(true); }); it('passes when user is a sudo user', () => { diff --git a/test/api/v3/unit/middlewares/ensureDevelpmentMode.js b/test/api/v3/unit/middlewares/ensureDevelpmentMode.js index 0815bc0007..c753740204 100644 --- a/test/api/v3/unit/middlewares/ensureDevelpmentMode.js +++ b/test/api/v3/unit/middlewares/ensureDevelpmentMode.js @@ -22,7 +22,8 @@ describe('developmentMode middleware', () => { ensureDevelpmentMode(req, res, next); - expect(next).to.be.calledWith(new NotFound()); + const calledWith = next.getCall(0).args; + expect(calledWith[0] instanceof NotFound).to.equal(true); }); it('passes when not in production', () => {