generated from Greenstand/treetracker-microservice-template
-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
The current test route: planters?organization_id=1&limit=1
This route only passes the test because the organization and planter both have id=1. But the truth is that the planter id is being overwritten by the object id.
If we use a different route such as: /planters?organization_id=178&limit=1 then the return object will have id=178. This is the organization id, but it is supposed to return the planter object which has id=2001.
Example of a test that should pass based on current database:
it(
'get planter by organization id',
async () => {
const response = await supertest(app).get(
'/planters?organization_id=178&limit=1',
);
expect(response.status).toBe(200);
expect(response.body.planters).toBeInstanceOf(Array);
expect(response.body.planters[0]).toMatchObject({
id: 2001,
organization_id: 1,
links: {
featured_trees: expect.stringMatching(/trees/),
associated_organizations: expect.stringMatching(/organizations/),
species: expect.stringMatching(/species/),
},
});
},
1000 * 30,
);Metadata
Metadata
Assignees
Labels
No labels