mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
add remaining test cases for ordered stop resolvers
This commit is contained in:
@@ -261,23 +261,48 @@ describe("OrderedStopResolvers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("stop", () => {
|
describe("stop", () => {
|
||||||
const query = `
|
async function getResponseForStopQuery(stopId: string) {
|
||||||
query GetNextStop($systemId: ID!, $routeId: ID!, $stopId: ID!) {
|
const query = `
|
||||||
system(id: $systemId) {
|
query GetNextStop($systemId: ID!, $routeId: ID!, $stopId: ID!) {
|
||||||
route(id: $routeId) {
|
system(id: $systemId) {
|
||||||
orderedStop(forStopId: $stopId) {
|
route(id: $routeId) {
|
||||||
stop {
|
orderedStop(forStopId: $stopId) {
|
||||||
name
|
stop {
|
||||||
id
|
name
|
||||||
|
id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
return await testServer.executeOperation({
|
||||||
|
query,
|
||||||
|
variables: {
|
||||||
|
systemId: mockSystem.id,
|
||||||
|
routeId: mockRoute.id,
|
||||||
|
stopId,
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
contextValue: {
|
||||||
|
repository,
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
`;
|
|
||||||
|
|
||||||
it("returns the associated stop if it exists", async () => {
|
it("returns the associated stop if it exists", async () => {
|
||||||
|
const orderedStops = await setUpOrderedStopsInRepository();
|
||||||
|
orderedStops[0].stopId = mockStops[0].id;
|
||||||
|
await repository.addOrUpdateOrderedStop(orderedStops[0]);
|
||||||
|
|
||||||
|
const response = await getResponseForStopQuery(orderedStops[0].stopId);
|
||||||
|
|
||||||
|
assert(response.body.kind === "single");
|
||||||
|
expect(response.body.singleResult.errors).toBeUndefined();
|
||||||
|
const stop = (response.body.singleResult.data?.system as any).route.orderedStop.stop;
|
||||||
|
expect(stop.name).toEqual(mockStops[0].name);
|
||||||
|
expect(stop.id).toEqual(mockStops[0].id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user