Upgrade sinonjs (and related libs) (#9914)

* update sinon

* remove errors

* fix unit tests
This commit is contained in:
Matteo Pagliazzi
2018-01-31 10:56:32 +01:00
committed by GitHub
parent 47dbe4561f
commit a85282763f
12 changed files with 129 additions and 19 deletions

112
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -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);

View File

@@ -47,7 +47,7 @@ describe('#upgradeGroupPlan', () => {
});
afterEach(function () {
sinon.restore(amzLib.authorizeOnBillingAgreement);
amzLib.authorizeOnBillingAgreement.restore();
uuid.v4.restore();
});

View File

@@ -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';

View File

@@ -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';

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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();

View File

@@ -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,

View File

@@ -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', () => {

View File

@@ -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', () => {