Skip to content

Commit

Permalink
Merge pull request #1590 from opencollective/packages/update-chai
Browse files Browse the repository at this point in the history
Update chai to version 4.2.0
  • Loading branch information
znarf authored Jan 7, 2019
2 parents 6c8c3e2 + 8266d91 commit 5c3b37d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 50 deletions.
39 changes: 13 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"@babel/register": "7.0.0",
"babel-eslint": "^10.0.1",
"babel-plugin-istanbul": "^5.1.0",
"chai": "^3.5.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-jest-snapshot": "^2.0.0",
"chance": "^1.0.18",
Expand Down
12 changes: 6 additions & 6 deletions test/discover.routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('discover', () => {
const ids = body.collectives.map(c => c.id);
expect(body.show).equal('all');
expect(body.sort).equal('most popular');
expect(body.collectives).to.be.Array;
expect(body.collectives).to.be.an('array');
expect(body.collectives.length).equal(2);
expect(body.total).equal(2);
expect(ids.indexOf(collective1.id)).not.equal(-1);
Expand All @@ -69,7 +69,7 @@ describe('discover', () => {
const ids = body.collectives.map(c => c.id);
expect(body.show).equal('open source');
expect(body.sort).equal('most popular');
expect(body.collectives).to.be.Array;
expect(body.collectives).to.be.an('array');
expect(body.collectives.length).equal(1);
expect(body.total).equal(1);
expect(ids.indexOf(collective1.id)).not.equal(-1);
Expand All @@ -88,7 +88,7 @@ describe('discover', () => {
const ids = body.collectives.map(c => c.id);
expect(body.show).equal('meetup');
expect(body.sort).equal('most popular');
expect(body.collectives).to.be.Array;
expect(body.collectives).to.be.an('array');
expect(body.collectives.length).equal(1);
expect(body.total).equal(1);
expect(ids.indexOf(collective1.id)).equal(-1);
Expand All @@ -106,7 +106,7 @@ describe('discover', () => {
const { body } = res;
expect(body.show).equal('undefined');
expect(body.sort).equal('most popular');
expect(body.collectives).to.be.Array;
expect(body.collectives).to.be.an('array');
expect(body.collectives.length).equal(0);
expect(body.total).equal(0);
done();
Expand All @@ -122,7 +122,7 @@ describe('discover', () => {
const ids = body.collectives.map(c => c.id);
expect(body.show).equal('all');
expect(body.sort).equal('newest');
expect(body.collectives).to.be.Array;
expect(body.collectives).to.be.an('array');
expect(body.collectives.length).equal(2);
expect(body.total).equal(2);
expect(ids.indexOf(collective1.id)).not.equal(-1);
Expand All @@ -142,7 +142,7 @@ describe('discover', () => {
const ids = body.collectives.map(c => c.id);
expect(body.show).equal('all');
expect(body.sort).equal('most popular');
expect(body.collectives).to.be.Array;
expect(body.collectives).to.be.an('array');
expect(body.collectives.length).equal(2);
expect(body.total).equal(2);
expect(ids.indexOf(collective1.id)).not.equal(-1);
Expand Down
8 changes: 4 additions & 4 deletions test/graphql.addFunds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('graphql.addFunds', () => {

// Then it should be a successful call
gqlResult.errors && console.error(gqlResult.errors[0]);
expect(gqlResult.errors).to.be.empty;
expect(gqlResult.errors).to.be.undefined;

// And then there should be a new payment method created in the
// database
Expand All @@ -61,7 +61,7 @@ describe('graphql.addFunds', () => {
// When the funds are added twice
const gqlResult0 = await utils.graphqlQuery(addFundsToOrgQuery, args, user);
gqlResult0.errors && console.error(gqlResult0.errors[0]);
expect(gqlResult0.errors).to.be.empty;
expect(gqlResult0.errors).to.be.undefined;

// changing some properties on the second query parameters
args.totalAmount = 3000;
Expand All @@ -70,7 +70,7 @@ describe('graphql.addFunds', () => {
// executing second query
const gqlResult1 = await utils.graphqlQuery(addFundsToOrgQuery, args, user);
gqlResult1.errors && console.error(gqlResult1.errors[0]);
expect(gqlResult1.errors).to.be.empty;
expect(gqlResult1.errors).to.be.undefined;

// changing some properties on the second query parameters
args.totalAmount = 4000;
Expand All @@ -79,7 +79,7 @@ describe('graphql.addFunds', () => {
// executing second query
const gqlResult2 = await utils.graphqlQuery(addFundsToOrgQuery, args, user);
gqlResult2.errors && console.error(gqlResult2.errors[0]);
expect(gqlResult2.errors).to.be.empty;
expect(gqlResult2.errors).to.be.undefined;

// And then there should be 2 payment methods created in the
// database
Expand Down
5 changes: 3 additions & 2 deletions test/graphql.cancelSubscription.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sinon from 'sinon';
import nodemailer from 'nodemailer';
import { expect } from 'chai';
import { assert, expect } from 'chai';
import config from 'config';
import * as utils from '../test/utils';
import models from '../server/models';
Expand Down Expand Up @@ -167,7 +167,8 @@ describe('graphql.cancelSubscriptions.test.js', () => {
where: { type: 'subscription.canceled' },
});

expect(activity).to.be.defined;
assert.isDefined(activity);

expect(activity.CollectiveId).to.be.equal(collective.id);
expect(activity.UserId).to.be.equal(user.id);
expect(activity.data.subscription.id).to.be.equal(order.SubscriptionId);
Expand Down
19 changes: 11 additions & 8 deletions test/paymentMethods.opencollective.virtualcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ describe('opencollective.virtualcard', () => {
const gqlResult = await utils.graphqlQuery(createPaymentMethodQuery, args, user1);

gqlResult.errors && console.error(gqlResult.errors[0]);
expect(gqlResult.errors).to.be.empty;
expect(gqlResult.errors).to.be.undefined;

const paymentMethod = await models.PaymentMethod.findById(gqlResult.data.createPaymentMethod.id);
expect(paymentMethod).to.exist;
expect(paymentMethod.limitedToTags).to.contain('open source');
Expand Down Expand Up @@ -683,7 +684,8 @@ describe('opencollective.virtualcard', () => {
const gqlResult = await utils.graphqlQuery(claimPaymentMethodQuery, args);

gqlResult.errors && console.error(gqlResult.errors[0]);
expect(gqlResult.errors).to.be.empty;
expect(gqlResult.errors).to.be.undefined;

const paymentMethod = gqlResult.data.claimPaymentMethod;
// payment method should exist
expect(paymentMethod).to.exist;
Expand Down Expand Up @@ -736,7 +738,7 @@ describe('opencollective.virtualcard', () => {
const gqlResult = await utils.graphqlQuery(claimPaymentMethodQuery, args, existingUser);

gqlResult.errors && console.error(gqlResult.errors[0]);
expect(gqlResult.errors).to.be.empty;
expect(gqlResult.errors).to.be.undefined;

const paymentMethod = await models.PaymentMethod.findById(gqlResult.data.claimPaymentMethod.id);

Expand Down Expand Up @@ -887,7 +889,7 @@ describe('opencollective.virtualcard', () => {
};
// Executing queries
const gqlResult = await utils.graphqlQuery(createOrderQuery, { order }, userVirtualCard);
expect(gqlResult.errors).to.not.be.empty;
expect(gqlResult.errors).to.be.an('array');
expect(gqlResult.errors[0]).to.exist;
expect(gqlResult.errors[0].toString()).to.contain("You don't have enough funds available");
}); /** End Of "Order should NOT be executed because its amount exceeds the balance of the virtual card" */
Expand All @@ -902,7 +904,7 @@ describe('opencollective.virtualcard', () => {
};
// Executing queries
const gqlResult = await utils.graphqlQuery(createOrderQuery, { order }, userVirtualCard);
expect(gqlResult.errors).to.not.be.empty;
expect(gqlResult.errors).to.be.an('array');
expect(gqlResult.errors[0]).to.exist;
expect(gqlResult.errors[0].toString()).to.contain(
'This payment method can only be used for collectives in open source',
Expand All @@ -920,7 +922,7 @@ describe('opencollective.virtualcard', () => {
};
// Executing queries
const gqlResult = await utils.graphqlQuery(createOrderQuery, { order }, userVirtualCard);
expect(gqlResult.errors).to.not.be.empty;
expect(gqlResult.errors).to.be.an('array');
expect(gqlResult.errors[0]).to.exist;
expect(gqlResult.errors[0].toString()).to.contain(
'This payment method can only be used for collectives hosted by Host 1',
Expand All @@ -939,7 +941,8 @@ describe('opencollective.virtualcard', () => {
const gqlResult = await utils.graphqlQuery(createOrderQuery, { order }, userVirtualCard);

gqlResult.errors && console.error(gqlResult.errors[0]);
expect(gqlResult.errors).to.be.empty;
expect(gqlResult.errors).to.be.undefined;

const transactions = await models.Transaction.findAll({
where: {
OrderId: gqlResult.data.createOrder.id,
Expand Down Expand Up @@ -978,7 +981,7 @@ describe('opencollective.virtualcard', () => {
await utils.graphqlQuery(createOrderQuery, { order }, userVirtualCard);
const gqlResult = await utils.graphqlQuery(createOrderQuery, { order }, userVirtualCard);

expect(gqlResult.errors).to.not.be.empty;
expect(gqlResult.errors).to.be.an('array');
expect(gqlResult.errors[0]).to.exist;
expect(gqlResult.errors[0].toString()).to.contain("You don't have enough funds available");
}); /** End Of "should fail when multiple orders exceed the balance of the virtual card" */
Expand Down
1 change: 0 additions & 1 deletion test/userlib.spec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ describe('userlib', () => {
.then(() => userlib.fetchAvatar(userData1.email))
.then(image => {
expect(stub.callCount).to.equal(1);
expect(image).to.be.falsy;
expect(image).to.equal(null);
}));
});
4 changes: 2 additions & 2 deletions test/xss.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'chai';
import { assert, expect } from 'chai';
import sinon from 'sinon';
import request from 'supertest';

Expand Down Expand Up @@ -86,7 +86,7 @@ describe('XSS.test', () => {

it('should call next callback', () => {
middleware()(req, {}, next);
expect(next).calledOnce;
assert(next.calledOnce);
});
});

Expand Down

0 comments on commit 5c3b37d

Please sign in to comment.