|
| 1 | +import { createCheckers } from "ts-interface-checker"; |
| 2 | + |
| 3 | +// checker model |
| 4 | +import FreeBikeStatusTI from "../v2.3/test-type-checkers/free_bike_status-ti"; |
| 5 | +import GbfsVersionsTI from "../v2.3/test-type-checkers/gbfs_versions-ti"; |
| 6 | +import GbfsTI from "../v2.3/test-type-checkers/gbfs-ti"; |
| 7 | +import GeofencingZonesTI from "../v2.3/test-type-checkers/geofencing_zones-ti"; |
| 8 | +import StationsInformationTI from "../v2.3/test-type-checkers/station_information-ti"; |
| 9 | +import StationStatusTI from "../v2.3/test-type-checkers/station_status-ti"; |
| 10 | +import SystemAlertsTI from "../v2.3/test-type-checkers/system_alerts-ti"; |
| 11 | +import SystemCalendarTI from "../v2.3/test-type-checkers/system_calendar-ti"; |
| 12 | +import SystemHoursTI from "../v2.3/test-type-checkers/system_hours-ti"; |
| 13 | +import SystemInformationTI from "../v2.3/test-type-checkers/system_information-ti"; |
| 14 | +import SystemPricingPlansTI from "../v2.3/test-type-checkers/system_pricing_plans-ti"; |
| 15 | +import SystemRegionsTI from "../v2.3/test-type-checkers/system_regions-ti"; |
| 16 | +import VehicleTypesTI from "../v2.3/test-type-checkers/vehicle_types-ti"; |
| 17 | + |
| 18 | +// checkers |
| 19 | +const { FreeBikeStatus } = createCheckers(FreeBikeStatusTI); |
| 20 | +const { GbfsVersions } = createCheckers(GbfsVersionsTI); |
| 21 | +const { Gbfs } = createCheckers(GbfsTI); |
| 22 | +const { GeofencingZones } = createCheckers(GeofencingZonesTI); |
| 23 | +const { StationInformation } = createCheckers(StationsInformationTI); |
| 24 | +const { StationStatus } = createCheckers(StationStatusTI); |
| 25 | +const { SystemAlerts } = createCheckers(SystemAlertsTI); |
| 26 | +const { SystemCalendar } = createCheckers(SystemCalendarTI); |
| 27 | +const { SystemHours } = createCheckers(SystemHoursTI); |
| 28 | +const { SystemInformation } = createCheckers(SystemInformationTI); |
| 29 | +const { SystemPricingPlans } = createCheckers(SystemPricingPlansTI); |
| 30 | +const { SystemRegions } = createCheckers(SystemRegionsTI); |
| 31 | +const { VehicleTypes } = createCheckers(VehicleTypesTI); |
| 32 | + |
| 33 | +// json test data: these are gbfs with no errors for v2.3 |
| 34 | +import freeBikeStatusJson from "../../../testFixtures/v2.3/free_bike_status.json"; |
| 35 | +import gbfsVersionsJson from "../../../testFixtures/v2.3/gbfs_versions.json"; |
| 36 | +import gbfsJson from "../../../testFixtures/v2.3/gbfs.json"; |
| 37 | +import geofencingZonesJson from "../../../testFixtures/v2.3/geofencing_zones.json"; |
| 38 | +import stationInformationJson from "../../../testFixtures/v2.3/station_information.json"; |
| 39 | +import stationStatusJson from "../../../testFixtures/v2.3/station_status.json"; |
| 40 | +import systemAlertsJson from "../../../testFixtures/v2.3/system_alerts.json"; |
| 41 | +import systemCalendarJson from "../../../testFixtures/v2.3/system_calendar.json"; |
| 42 | +import systemHoursJson from "../../../testFixtures/v2.3/system_hours.json"; |
| 43 | +import systemInformationJson from "../../../testFixtures/v2.3/system_information.json"; |
| 44 | +import systemPricingPlansJson from "../../../testFixtures/v2.3/system_pricing_plans.json"; |
| 45 | +import systemRegionsJson from "../../../testFixtures/v2.3/system_regions.json"; |
| 46 | +import vehicleTypesJson from "../../../testFixtures/v2.3/vehicle_types.json"; |
| 47 | + |
| 48 | +// Date objects cannot be represented in JSON |
| 49 | +// Manual checks for dates are required |
| 50 | +describe("GBFS Validator v2.3", () => { |
| 51 | + it("should check if gbfs_versions is valid", () => { |
| 52 | + expect(() => { |
| 53 | + GbfsVersions.check(gbfsVersionsJson); |
| 54 | + }).not.toThrow(); |
| 55 | + }); |
| 56 | + |
| 57 | + it("should check if gbfs is valid", () => { |
| 58 | + expect(() => { |
| 59 | + Gbfs.check(gbfsJson); |
| 60 | + }).not.toThrow(); |
| 61 | + }); |
| 62 | + |
| 63 | + it("should check if geofencing_zones is valid", () => { |
| 64 | + expect(() => { |
| 65 | + GeofencingZones.check(geofencingZonesJson); |
| 66 | + }).not.toThrow(); |
| 67 | + }); |
| 68 | + |
| 69 | + it("should check if station_information is valid", () => { |
| 70 | + expect(() => { |
| 71 | + StationInformation.check(stationInformationJson); |
| 72 | + }).not.toThrow(); |
| 73 | + }); |
| 74 | + |
| 75 | + it("should check if station_status is valid", () => { |
| 76 | + expect(() => { |
| 77 | + StationStatus.check(stationStatusJson); |
| 78 | + }).not.toThrow(); |
| 79 | + }); |
| 80 | + |
| 81 | + it("should check if system_alerts is valid", () => { |
| 82 | + expect(() => { |
| 83 | + SystemAlerts.check(systemAlertsJson); |
| 84 | + }).not.toThrow(); |
| 85 | + }); |
| 86 | + |
| 87 | + it("should check if system_information is valid", () => { |
| 88 | + expect(() => { |
| 89 | + SystemCalendar.check(systemCalendarJson); |
| 90 | + }).not.toThrow(); |
| 91 | + }); |
| 92 | + |
| 93 | + it("should check if system_information is valid", () => { |
| 94 | + expect(() => { |
| 95 | + SystemHours.check(systemHoursJson); |
| 96 | + }).not.toThrow(); |
| 97 | + }); |
| 98 | + |
| 99 | + it("should check if system_information is valid", () => { |
| 100 | + expect(() => { |
| 101 | + SystemInformation.check(systemInformationJson); |
| 102 | + }).not.toThrow(); |
| 103 | + }); |
| 104 | + |
| 105 | + it("should check if system_pricing_plans is valid", () => { |
| 106 | + expect(() => { |
| 107 | + SystemPricingPlans.check(systemPricingPlansJson); |
| 108 | + }).not.toThrow(); |
| 109 | + }); |
| 110 | + |
| 111 | + it("should check if system_regions is valid", () => { |
| 112 | + expect(() => { |
| 113 | + SystemRegions.check(systemRegionsJson); |
| 114 | + }).not.toThrow(); |
| 115 | + }); |
| 116 | + |
| 117 | + it("should check if vehicle_status is valida", () => { |
| 118 | + expect(() => { |
| 119 | + FreeBikeStatus.check(freeBikeStatusJson); |
| 120 | + }).not.toThrow(); |
| 121 | + }); |
| 122 | + |
| 123 | + it("should check if vehicle_types is valid", () => { |
| 124 | + expect(() => { |
| 125 | + VehicleTypes.check(vehicleTypesJson); |
| 126 | + }).not.toThrow(); |
| 127 | + }); |
| 128 | +}); |
0 commit comments