fix TS errors, add missing tests
This commit is contained in:
1 parent
b515d688f4
commit
4d1af5e2b4
4 files changed
+62
No files matched your search
@@ -359,6 +359,19 @@ describe("MonitorService", () => {
|
||||
"monitors are not supported for hardware details"
|
||||
);
|
||||
});
|
||||
|
||||
it("throws 500 when checksData monitorType is not hardware", async () => {
|
||||
const monitorsRepository = createMonitorsRepositoryMock();
|
||||
const checksRepository = createChecksRepositoryMock();
|
||||
const monitor = makeMonitor({ type: "hardware" });
|
||||
(monitorsRepository.findById as jest.Mock).mockResolvedValue(monitor);
|
||||
(checksRepository.findByDateRangeAndMonitorId as jest.Mock).mockResolvedValue({ monitorType: "http" });
|
||||
const { service } = createService({ monitorsRepository, checksRepository });
|
||||
|
||||
await expect(service.getHardwareDetailsById({ teamId: TEAM_ID, monitorId: MONITOR_ID, dateRange: "recent" })).rejects.toThrow(
|
||||
"Unable to load hardware stats for this monitor"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getPageSpeedDetailsById", () => {
|
||||
@@ -403,6 +416,19 @@ describe("MonitorService", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("throws 500 when checksData monitorType is not pagespeed", async () => {
|
||||
const monitorsRepository = createMonitorsRepositoryMock();
|
||||
const checksRepository = createChecksRepositoryMock();
|
||||
const monitor = makeMonitor({ type: "pagespeed" });
|
||||
(monitorsRepository.findById as jest.Mock).mockResolvedValue(monitor);
|
||||
(checksRepository.findByDateRangeAndMonitorId as jest.Mock).mockResolvedValue({ monitorType: "http" });
|
||||
const { service } = createService({ monitorsRepository, checksRepository });
|
||||
|
||||
await expect(service.getPageSpeedDetailsById({ teamId: TEAM_ID, monitorId: MONITOR_ID, dateRange: "recent" })).rejects.toThrow(
|
||||
"Unable to load pagespeed stats for this monitor"
|
||||
);
|
||||
});
|
||||
|
||||
it("handles pagespeed with different date range", async () => {
|
||||
const monitorsRepository = createMonitorsRepositoryMock();
|
||||
const checksRepository = createChecksRepositoryMock();
|
||||
|
||||
Reference in new issue
Block a user