Skip to content

Commit

Permalink
test: make explorer smoke test cover more
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Oct 8, 2023
1 parent afa670f commit 243846d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/cli/test/behavior/explorer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class _MockShipyardPrices extends Mock implements ShipyardPrices {}

class _MockSystemsCache extends Mock implements SystemsCache {}

class _MockSystemConnectivity extends Mock implements SystemConnectivity {}

class _MockWaypoint extends Mock implements Waypoint {}

class _MockWaypointCache extends Mock implements WaypointCache {}
Expand Down Expand Up @@ -62,13 +64,30 @@ void main() {
when(() => caches.systems).thenReturn(systemsCache);
when(() => caches.shipyardPrices).thenReturn(shipyardPrices);
when(() => caches.charting).thenReturn(chartingCache);
final systemConnectivity = _MockSystemConnectivity();
when(() => caches.systemConnectivity).thenReturn(systemConnectivity);

final waypoint = _MockWaypoint();
final waypointSymbol = WaypointSymbol.fromString('S-A-B');
when(() => waypoint.symbol).thenReturn('S-A-B');
when(() => waypoint.systemSymbol).thenReturn('S-A');
when(() => waypoint.type).thenReturn(WaypointType.PLANET);
when(() => waypoint.traits).thenReturn([]);
when(() => waypoint.chart).thenReturn(Chart());

final system = System(
symbol: waypointSymbol.system,
sectorSymbol: waypointSymbol.sector,
type: SystemType.BLACK_HOLE,
x: 0,
y: 0,
);
when(() => systemsCache.systemBySymbol(waypointSymbol.systemSymbol))
.thenReturn(system);
registerFallbackValue(waypointSymbol.systemSymbol);
when(() => systemConnectivity.clusterIdForSystem(any())).thenReturn(0);
when(() => systemConnectivity.systemSymbolsByClusterId(0))
.thenReturn([waypointSymbol.systemSymbol]);

when(() => api.fleet).thenReturn(fleetApi);
when(() => fleetApi.createChart(any())).thenAnswer(
Expand All @@ -83,14 +102,20 @@ void main() {
when(() => ship.symbol).thenReturn(shipSymbol.symbol);
when(() => ship.nav).thenReturn(shipNav);
when(() => shipNav.status).thenReturn(ShipNavStatus.DOCKED);
when(() => shipNav.waypointSymbol).thenReturn('S-A-W');
when(() => shipNav.waypointSymbol).thenReturn(waypointSymbol.waypoint);
when(() => shipNav.systemSymbol).thenReturn(waypointSymbol.system);
final shipFuel = ShipFuel(capacity: 100, current: 100);
when(() => ship.fuel).thenReturn(shipFuel);

registerFallbackValue(waypointSymbol);
when(() => waypointCache.waypoint(any()))
.thenAnswer((_) => Future.value(waypoint));

when(() => centralCommand.maxAgeForExplorerData)
.thenReturn(const Duration(days: 3));
when(centralCommand.shortenMaxAgeForExplorerData)
.thenReturn(const Duration(days: 1));
when(() => centralCommand.otherExplorerSystems(shipSymbol)).thenReturn([]);
final state = BehaviorState(shipSymbol, Behavior.explorer);

final logger = _MockLogger();
Expand Down

0 comments on commit 243846d

Please sign in to comment.