Updated to latest React (Security Issue), updated tests to new react version
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
|
||||
import { describe, it, expect, setSystemTime, beforeAll, afterAll } from "bun:test";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { VehicleList } from "./VehicleList";
|
||||
import { Vehicle } from "@/lib/api";
|
||||
// We don't have full React DOM testing setup easily with basic Bun test runner for components usually needing jsdom
|
||||
// But we can test that the file interprets and imports correctly.
|
||||
// A simple smoke test to ensure no runtime errors on import instantiation.
|
||||
|
||||
describe("VehicleList Component", () => {
|
||||
it("should instantiate without runtime errors (smoke test)", () => {
|
||||
@@ -12,9 +11,6 @@ describe("VehicleList Component", () => {
|
||||
});
|
||||
|
||||
it("should process vehicles without error", () => {
|
||||
// Since we can't fully render JSX without a DOM in standard bun test (unless configured with happy-dom),
|
||||
// we can at least invoke the function if it's a functional component to see if it executes logic up to return.
|
||||
// Note: Hook calls (useClient) or Context might fail if not mocked, but VehicleList is simple.
|
||||
const vehicles: Vehicle[] = [{
|
||||
vin: "TEST",
|
||||
status: "Online",
|
||||
@@ -24,13 +20,14 @@ describe("VehicleList Component", () => {
|
||||
}];
|
||||
|
||||
try {
|
||||
const result = VehicleList({ vehicles, groups: [] });
|
||||
expect(result).toBeDefined();
|
||||
// Now we can properly render the component which handles hooks correctly
|
||||
render(<VehicleList vehicles={vehicles} groups={[]} />);
|
||||
// Check if content renders (assuming "Fleet Overview" is present as per component code)
|
||||
expect(screen.getByText("Fleet Overview")).toBeDefined();
|
||||
expect(screen.getByText("TEST")).toBeDefined();
|
||||
} catch (e) {
|
||||
// If it fails on hook or DOM, that's expected in this environment
|
||||
// but if it fails on "Can't find variable", that's what we want to catch.
|
||||
// VehicleList doesn't use hooks, so it might actually run!
|
||||
// console.error(e);
|
||||
console.error(e);
|
||||
throw e; // Fail test if render throws
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user