Skip to content

Commit

Permalink
Remove dependency on return order of many-relationships in api-tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Jul 23, 2020
1 parent 5a38498 commit 50d33dd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 36 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-maps-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/api-tests': patch
---

Updated tests to not depend on resolver order.
14 changes: 6 additions & 8 deletions api-tests/relationships/crud/many-to-many.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,9 @@ multiAdapterRunners().map(({ runner, adapterName }) =>
linkedCompanies.forEach(({ locations }) => {
expect(locations.map(({ id }) => id)).toEqual([Location.id.toString()]);
});
expect(linkedCompanies[0].locations[0].companies).toEqual([
{ id: linkedCompanies[0].id },
{ id: linkedCompanies[1].id },
]);
expect(linkedCompanies[0].locations[0].companies.map(({ id }) => id).sort()).toEqual(
[linkedCompanies[0].id, linkedCompanies[1].id].sort()
);
})
);

Expand Down Expand Up @@ -371,10 +370,9 @@ multiAdapterRunners().map(({ runner, adapterName }) =>
allCompanies.forEach(({ locations }) => {
expect(locations.map(({ id }) => id)).toEqual([Location.id.toString()]);
});
expect(allCompanies[0].locations[0].companies).toEqual([
{ id: allCompanies[0].id },
{ id: allCompanies[1].id },
]);
expect(allCompanies[0].locations[0].companies.map(({ id }) => id).sort()).toEqual(
[allCompanies[0].id, allCompanies[1].id].sort()
);
})
);
});
Expand Down
22 changes: 6 additions & 16 deletions api-tests/relationships/filtering/filtering.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,10 @@ multiAdapterRunners().map(({ runner, adapterName }) =>

expect(errors).toBe(undefined);
expect(data).toHaveProperty('allUsers.0.posts');
expect(data.allUsers).toHaveLength(1);
expect(data.allUsers[0].id).toEqual(user.id);
expect(data.allUsers[0].posts).toHaveLength(3);
expect(data).toMatchObject({
allUsers: [
{
id: user.id,
posts: [{ id: ids[0] }, { id: ids[1] }, { id: ids[2] }],
},
],
});
expect(data.allUsers[0].posts.map(({ id }) => id).sort()).toEqual(ids.sort());
})
);

Expand Down Expand Up @@ -203,15 +198,10 @@ multiAdapterRunners().map(({ runner, adapterName }) =>

expect(errors).toBe(undefined);
expect(data).toHaveProperty('allUsers.0.posts');
expect(data.allUsers).toHaveLength(1);
expect(data.allUsers[0].id).toEqual(user.id);
expect(data.allUsers[0].posts).toHaveLength(3);
expect(data).toMatchObject({
allUsers: [
{
id: user.id,
posts: [{ id: ids[0] }, { id: ids[1] }, { id: ids[2] }],
},
],
});
expect(data.allUsers[0].posts.map(({ id }) => id).sort()).toEqual(ids.sort());
})
);

Expand Down
19 changes: 7 additions & 12 deletions api-tests/relationships/filtering/nested.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,14 @@ multiAdapterRunners().map(({ runner, adapterName }) =>

expect(errors).toBe(undefined);
expect(data).toHaveProperty('allUsers.0.posts');
expect(data.allUsers).toHaveLength(2);
expect(data.allUsers[0].id).toEqual(user.id);
expect(data.allUsers[0].posts).toHaveLength(2);
expect(data).toMatchObject({
allUsers: [
{
id: user.id,
posts: [{ id: ids[1] }, { id: ids[2] }],
},
{
id: user2.id,
posts: [],
},
],
});
expect(data.allUsers[0].posts.map(({ id }) => id).sort()).toEqual(
[ids[1], ids[2]].sort()
);
expect(data.allUsers[1].id).toEqual(user2.id);
expect(data.allUsers[1].posts).toHaveLength(0);
})
);

Expand Down

0 comments on commit 50d33dd

Please sign in to comment.