mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 08:50:29 +00:00
implement endpoints and update test
This commit is contained in:
@@ -78,11 +78,27 @@ export const SystemResolvers: Resolvers<ServerContext> = {
|
|||||||
|
|
||||||
return await system.shuttleRepository.getShuttles();
|
return await system.shuttleRepository.getShuttles();
|
||||||
},
|
},
|
||||||
parkingStructures: async (_parent, _args, _contextValue, _info) => {
|
parkingStructures: async (parent, _args, contextValue, _info) => {
|
||||||
return [];
|
const system = contextValue.findSystemById(parent.id);
|
||||||
|
if (!system) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const parkingRepository = system.parkingRepository;
|
||||||
|
if (!parkingRepository) return [];
|
||||||
|
|
||||||
|
return await parkingRepository.getParkingStructures();
|
||||||
},
|
},
|
||||||
parkingStructure: async (_parent, _args, _contextValue, _info) => {
|
parkingStructure: async (parent, args, contextValue, info) => {
|
||||||
return null;
|
if (!args.id) return null;
|
||||||
|
|
||||||
|
const system = contextValue.findSystemById(parent.id);
|
||||||
|
if (!system) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const parkingRepository = system.parkingRepository;
|
||||||
|
if (!parkingRepository) return null;
|
||||||
|
|
||||||
|
return await parkingRepository.getParkingStructureById(args.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ describe("SystemResolvers", () => {
|
|||||||
expect(parkingStructures).toHaveLength(0);
|
expect(parkingStructures).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns null if there is no parking data available", async () => {
|
it("returns a blank array if there is no parking data available", async () => {
|
||||||
context.systems[0].parkingTimedDataLoader = null;
|
context.systems[0].parkingTimedDataLoader = null;
|
||||||
context.systems[0].parkingRepository = null;
|
context.systems[0].parkingRepository = null;
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ describe("SystemResolvers", () => {
|
|||||||
assert(response.body.kind === "single");
|
assert(response.body.kind === "single");
|
||||||
expect(response.body.singleResult.errors).toBeUndefined();
|
expect(response.body.singleResult.errors).toBeUndefined();
|
||||||
const parkingStructures = (response.body.singleResult.data as any).system.parkingStructures;
|
const parkingStructures = (response.body.singleResult.data as any).system.parkingStructures;
|
||||||
expect(parkingStructures).toBeNull();
|
expect(parkingStructures).toHaveLength(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user