diff --git a/assets/tests/factories/vehicle_data.ts b/assets/tests/factories/vehicle_data.ts index 4e1e06092..a9f1c701d 100644 --- a/assets/tests/factories/vehicle_data.ts +++ b/assets/tests/factories/vehicle_data.ts @@ -1,90 +1,92 @@ import { Factory } from "fishery" import { VehicleData } from "../../src/models/vehicleData" -export default Factory.define(({ sequence }) => ({ - id: `v${sequence}`, - label: `v${sequence}-label`, - run_id: `run-${sequence}`, - timestamp: 123, - latitude: 0, - longitude: 0, - direction_id: 0, - route_id: "39", - route_pattern_id: "39-_-0", - trip_id: `t${sequence}`, - headsign: "Forest Hills", - via_variant: "X", - operator_id: `op${sequence}`, - operator_first_name: "WILL", - operator_last_name: "SMITH", - operator_logon_time: Math.floor( - new Date("2018-08-15T13:38:21.000Z").getTime() / 1000 - ), - bearing: 33, - block_id: `block-${sequence}`, - previous_vehicle_id: `v${sequence + 1}`, - schedule_adherence_secs: 0, - incoming_trip_direction_id: null, - is_shuttle: false, - is_overload: false, - is_off_course: false, - is_revenue: true, - layover_departure_time: null, - pull_back_place_name: "Garage", - overload_offset: null, - sources: [], - data_discrepancies: [ - { - attribute: "trip_id", - sources: [ - { - id: "swiftly", - value: "swiftly-trip-id", - }, - { - id: "busloc", - value: "busloc-trip-id", - }, - ], - }, - { - attribute: "route_id", - sources: [ - { - id: "swiftly", - value: null, - }, - { - id: "busloc", - value: "busloc-route-id", - }, - ], - }, - ], - stop_status: { - stop_id: "s1", - stop_name: "Stop Name", - }, - timepoint_status: { - timepoint_id: "tp1", - fraction_until_timepoint: 0.5, - }, - scheduled_location: { +export const vehicleDataFactory = Factory.define( + ({ sequence }) => ({ + id: `v${sequence}`, + label: `v${sequence}-label`, + run_id: `run-${sequence}`, + timestamp: 123, + latitude: 0, + longitude: 0, + direction_id: 0, route_id: "39", route_pattern_id: "39-_-0", - direction_id: 0, - trip_id: "scheduled trip", - run_id: "scheduled run", - time_since_trip_start_time: 0, - headsign: "scheduled headsign", - via_variant: "scheduled via variant", + trip_id: `t${sequence}`, + headsign: "Forest Hills", + via_variant: "X", + operator_id: `op${sequence}`, + operator_first_name: "WILL", + operator_last_name: "SMITH", + operator_logon_time: Math.floor( + new Date("2018-08-15T13:38:21.000Z").getTime() / 1000 + ), + bearing: 33, + block_id: `block-${sequence}`, + previous_vehicle_id: `v${sequence + 1}`, + schedule_adherence_secs: 0, + incoming_trip_direction_id: null, + is_shuttle: false, + is_overload: false, + is_off_course: false, + is_revenue: true, + layover_departure_time: null, + pull_back_place_name: "Garage", + overload_offset: null, + sources: [], + data_discrepancies: [ + { + attribute: "trip_id", + sources: [ + { + id: "swiftly", + value: "swiftly-trip-id", + }, + { + id: "busloc", + value: "busloc-trip-id", + }, + ], + }, + { + attribute: "route_id", + sources: [ + { + id: "swiftly", + value: null, + }, + { + id: "busloc", + value: "busloc-route-id", + }, + ], + }, + ], + stop_status: { + stop_id: "s1", + stop_name: "Stop Name", + }, timepoint_status: { timepoint_id: "tp1", fraction_until_timepoint: 0.5, }, - }, - route_status: "on_route", - end_of_trip_type: "another_trip", - block_waivers: [], - crowding: null, -})) + scheduled_location: { + route_id: "39", + route_pattern_id: "39-_-0", + direction_id: 0, + trip_id: "scheduled trip", + run_id: "scheduled run", + time_since_trip_start_time: 0, + headsign: "scheduled headsign", + via_variant: "scheduled via variant", + timepoint_status: { + timepoint_id: "tp1", + fraction_until_timepoint: 0.5, + }, + }, + route_status: "on_route", + end_of_trip_type: "another_trip", + block_waivers: [], + crowding: null, + }) +) diff --git a/assets/tests/hooks/useAutocompleteResults.test.ts b/assets/tests/hooks/useAutocompleteResults.test.ts index e263e53bb..6738c6db5 100644 --- a/assets/tests/hooks/useAutocompleteResults.test.ts +++ b/assets/tests/hooks/useAutocompleteResults.test.ts @@ -2,7 +2,7 @@ import { describe, test, expect } from "@jest/globals" import { useAutocompleteResults } from "../../src/hooks/useAutocompleteResults" import { renderHook } from "@testing-library/react" import { makeMockSocket, makeMockChannel } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" import { searchFiltersFactory } from "../factories/searchProperties" describe("useAutocompleteResults", () => { diff --git a/assets/tests/hooks/usePullbackVehicles.test.ts b/assets/tests/hooks/usePullbackVehicles.test.ts index 006d1b4b8..8debed1cf 100644 --- a/assets/tests/hooks/usePullbackVehicles.test.ts +++ b/assets/tests/hooks/usePullbackVehicles.test.ts @@ -3,7 +3,7 @@ import { renderHook } from "@testing-library/react" import usePullbackVehicles from "../../src/hooks/usePullbackVehicles" import { Vehicle } from "../../src/realtime.d" import { makeMockChannel, makeMockSocket } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" import { vehicleFromData } from "../../src/models/vehicleData" const pullBackVehicle = vehicleDataFactory.build({ diff --git a/assets/tests/hooks/useSearchResults.test.ts b/assets/tests/hooks/useSearchResults.test.ts index 8ba7912d3..c86c80c25 100644 --- a/assets/tests/hooks/useSearchResults.test.ts +++ b/assets/tests/hooks/useSearchResults.test.ts @@ -5,7 +5,7 @@ import { VehiclePropertyQuery } from "../../src/models/searchQuery" import { VehicleData, vehicleFromData } from "../../src/models/vehicleData" import { makeMockChannel, makeMockSocket } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" describe("useSearchResults", () => { test("when query given and loading, returns loading", () => { diff --git a/assets/tests/hooks/useShuttleVehicles.test.ts b/assets/tests/hooks/useShuttleVehicles.test.ts index ae677e5c5..2751c1737 100644 --- a/assets/tests/hooks/useShuttleVehicles.test.ts +++ b/assets/tests/hooks/useShuttleVehicles.test.ts @@ -3,7 +3,7 @@ import { renderHook } from "@testing-library/react" import useShuttleVehicles from "../../src/hooks/useShuttleVehicles" import { Vehicle } from "../../src/realtime.d" import { makeMockChannel, makeMockSocket } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" import { vehicleFromData } from "../../src/models/vehicleData" const shuttle = vehicleDataFactory.build({ is_shuttle: true }) diff --git a/assets/tests/hooks/useVehicleForId.test.ts b/assets/tests/hooks/useVehicleForId.test.ts index 5274a99a1..afcb04b38 100644 --- a/assets/tests/hooks/useVehicleForId.test.ts +++ b/assets/tests/hooks/useVehicleForId.test.ts @@ -3,7 +3,7 @@ import { makeMockOneShotChannel, makeMockSocket, } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" import { renderHook } from "@testing-library/react" import useVehicleForId from "../../src/hooks/useVehicleForId" diff --git a/assets/tests/hooks/useVehicleForNotification.test.tsx b/assets/tests/hooks/useVehicleForNotification.test.tsx index 279031fc5..daeaa715a 100644 --- a/assets/tests/hooks/useVehicleForNotification.test.tsx +++ b/assets/tests/hooks/useVehicleForNotification.test.tsx @@ -16,7 +16,7 @@ import { makeMockOneShotChannel, makeMockSocket, } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" import ghostDataFactory from "../factories/ghost_data" import { tagManagerEvent } from "../../src/helpers/googleTagManager" import { fullStoryEvent } from "../../src/helpers/fullStory" diff --git a/assets/tests/hooks/useVehicles.test.ts b/assets/tests/hooks/useVehicles.test.ts index 99f962ead..ea679a448 100644 --- a/assets/tests/hooks/useVehicles.test.ts +++ b/assets/tests/hooks/useVehicles.test.ts @@ -7,7 +7,7 @@ import { Ghost, Vehicle } from "../../src/realtime.d" import { RouteId } from "../../src/schedule.d" import { makeMockChannel, makeMockSocket } from "../testHelpers/socketHelpers" import ghostFactory from "../factories/ghost" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" import ghostDataFactory from "../factories/ghost_data" import * as Sentry from "@sentry/react" diff --git a/assets/tests/hooks/useVehiclesForBlockIds.test.ts b/assets/tests/hooks/useVehiclesForBlockIds.test.ts index 488f09ba3..0bbae3d7b 100644 --- a/assets/tests/hooks/useVehiclesForBlockIds.test.ts +++ b/assets/tests/hooks/useVehiclesForBlockIds.test.ts @@ -3,7 +3,7 @@ import { renderHook } from "@testing-library/react" import useVehicleForBlockIds from "../../src/hooks/useVehiclesForBlockIds" import { vehicleFromData } from "../../src/models/vehicleData" import { makeMockChannel, makeMockSocket } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" describe("useVehiclesForBlockIds", () => { test("returns data", () => { diff --git a/assets/tests/hooks/useVehiclesForRunIds.test.ts b/assets/tests/hooks/useVehiclesForRunIds.test.ts index f8db4fcee..6d2cc2aac 100644 --- a/assets/tests/hooks/useVehiclesForRunIds.test.ts +++ b/assets/tests/hooks/useVehiclesForRunIds.test.ts @@ -3,7 +3,7 @@ import { renderHook } from "@testing-library/react" import useVehiclesForRunIds from "../../src/hooks/useVehiclesForRunIds" import { VehicleData, vehicleFromData } from "../../src/models/vehicleData" import { makeMockChannel, makeMockSocket } from "../testHelpers/socketHelpers" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" describe("useVehiclesForRunIds", () => { test("returns data", () => { diff --git a/assets/tests/models/vehicleData.test.ts b/assets/tests/models/vehicleData.test.ts index b7802ef88..f38ebd7a0 100644 --- a/assets/tests/models/vehicleData.test.ts +++ b/assets/tests/models/vehicleData.test.ts @@ -2,7 +2,7 @@ import { describe, test, expect } from "@jest/globals" import { ghostFromData, vehicleFromData } from "../../src/models/vehicleData" import { dateFromEpochSeconds } from "../../src/util/dateTime" import ghostDataFactory from "../factories/ghost_data" -import vehicleDataFactory from "../factories/vehicle_data" +import { vehicleDataFactory } from "../factories/vehicle_data" describe("vehicleFromData", () => { test("returns vehicle data in expected format", () => {