mirror of
https://github.com/strapi/strapi.git
synced 2025-10-11 16:13:12 +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.statusCode).toBe(200);
|
||||||
expect(res.body).toEqual({
|
|
||||||
data: {
|
// same length
|
||||||
posts: expected,
|
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