mirror of
https://github.com/strapi/strapi.git
synced 2025-10-10 15:43:41 +00:00
Proper testing of lists without order
This commit is contained in:
parent
89594ea416
commit
c3001c00ff
@ -255,10 +255,18 @@ describe('Test Graphql API End to End', () => {
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toEqual({
|
||||
data: {
|
||||
posts: expected,
|
||||
},
|
||||
|
||||
// same length
|
||||
expect(res.body.data.posts.length).toBe(expected.length);
|
||||
|
||||
// all the posts returned are in the expected array
|
||||
res.body.data.posts.forEach(post => {
|
||||
expect(expected).toEqual(expect.arrayContaining([post]));
|
||||
});
|
||||
|
||||
// all expected values are in the result
|
||||
expected.forEach(expectedPost => {
|
||||
expect(res.body.data.posts).toEqual(expect.arrayContaining([expectedPost]));
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user