feat: build vehicle data platform and production pipeline

This commit is contained in:
lingniu
2026-07-14 12:35:33 +08:00
parent b452be3b94
commit bb59303a4b
270 changed files with 88016 additions and 1975 deletions

View File

@@ -0,0 +1,49 @@
import { render, screen } from '@testing-library/react';
import { afterEach, expect, test, vi } from 'vitest';
import { VehicleMap } from './VehicleMap';
class TestMap {
add = vi.fn();
addControl = vi.fn();
setFitView = vi.fn();
destroy = vi.fn();
constructor(
public container: HTMLDivElement,
public options: Record<string, unknown>
) {}
}
class TestOverlay {
setMap = vi.fn();
on = vi.fn();
}
class TestScale {}
afterEach(() => {
delete window.__LINGNIU_APP_CONFIG__;
delete window.AMapLoader;
vi.restoreAllMocks();
});
test('loads AMap base map even when realtime vehicle points are empty', async () => {
const mapLoad = vi.fn().mockResolvedValue({
Map: TestMap,
Marker: TestOverlay,
Polyline: TestOverlay,
Scale: TestScale
});
window.__LINGNIU_APP_CONFIG__ = { amapWebJsKey: 'amap-web-key' };
window.AMapLoader = { load: mapLoad };
render(<VehicleMap points={[]} fallbackLabel="等待真实车辆坐标" />);
expect(await screen.findByText('高德地图已加载')).toBeInTheDocument();
expect(screen.queryByText('等待真实车辆坐标')).not.toBeInTheDocument();
expect(mapLoad).toHaveBeenCalledWith({
key: 'amap-web-key',
version: '2.0',
plugins: ['AMap.Scale']
});
});