Skip to content

Commit

Permalink
add test to filter allExpenses(fromCollectiveSlug)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdamman committed Feb 22, 2018
1 parent 1b561e6 commit 8abc429
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/graphql.expenses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('graphql.collective.test.js', () => {
before(() => models.Collective.findOne({ where: { slug: 'railsgirlsatl' }}).then(c => collective = c));

const query = `
query allExpenses($CollectiveId: Int!, $category: String, $limit: Int, $includeHostedCollectives: Boolean) {
allExpenses(CollectiveId: $CollectiveId, category: $category, limit: $limit, includeHostedCollectives: $includeHostedCollectives) {
query allExpenses($CollectiveId: Int!, $category: String, $fromCollectiveSlug: String, $limit: Int, $includeHostedCollectives: Boolean) {
allExpenses(CollectiveId: $CollectiveId, category: $category, fromCollectiveSlug: $fromCollectiveSlug, limit: $limit, includeHostedCollectives: $includeHostedCollectives) {
id
description
amount
Expand Down Expand Up @@ -72,6 +72,15 @@ describe('graphql.collective.test.js', () => {
expect(expenses).to.have.length(5);
expect(expenses.map(e => e.category)).to.deep.equal([ 'Legal', 'Legal', 'Legal', 'Legal', 'Legal' ]);
});

it('gets the latest expenses from all the hosted collectives for one author', async () => {
const result = await utils.graphqlQuery(query, { fromCollectiveSlug: "xdamman", CollectiveId: host.id, limit: 5, includeHostedCollectives: true });
result.errors && console.error(result.errors);
expect(result.errors).to.not.exist;
const expenses = result.data.allExpenses;
expect(expenses).to.have.length(5);
expect(expenses.map(e => e.user.collective.slug)).to.deep.equal([ 'xdamman', 'xdamman', 'xdamman', 'xdamman', 'xdamman' ]);
});
});

describe("write", () => {
Expand Down

0 comments on commit 8abc429

Please sign in to comment.