Skip to content

Commit

Permalink
Sort test results before comparing (#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Aug 18, 2020
1 parent 4aad74c commit d492986
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-rats-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/api-tests': patch
---

Updated tests to compared sorted results.
5 changes: 3 additions & 2 deletions api-tests/access-control/authed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ const expectNoAccess = (data, errors, name) => {
const expectNamedArray = (data, errors, name, values) => {
expect(errors).toBe(undefined);
expect(data[name]).toHaveLength(values.length);
values.forEach((value, i) => {
expect(data[name][i].id).toEqual(value);
const sortedData = data[name].map(({ id }) => id).sort();
values.sort().forEach((value, i) => {
expect(sortedData[i]).toEqual(value);
});
};

Expand Down

0 comments on commit d492986

Please sign in to comment.