1
0
Fork 0
spacetac/src/ui/map/StarSystemDisplay.spec.ts
2019-11-21 23:14:27 +01:00

36 lines
1.2 KiB
TypeScript

import { testing } from "../../common/Testing";
import { first, nn } from "../../common/Tools";
import { Shop } from "../../core/Shop";
import { setupMapview } from "../TestGame";
testing("StarSystemDisplay", test => {
let testgame = setupMapview(test);
test.case("displays a badge with the current state for a star location", check => {
let mapview = testgame.view;
let location = mapview.player_fleet.location;
let ssdisplay = nn(first(mapview.starsystems, ss => ss.starsystem == location.star));
let ldisplay = nn(first(ssdisplay.locations, loc => loc[0] != location));
check.equals(ldisplay[2].name, "map-status-unvisited");
ldisplay[0].setupEncounter();
ssdisplay.updateInfo(2, true);
check.equals(ldisplay[2].name, "map-status-unvisited");
mapview.player.fleet.visited.push(ldisplay[0].id);
ssdisplay.updateInfo(2, true);
check.equals(ldisplay[2].name, "map-status-enemy");
ldisplay[0].shop = null;
ldisplay[0].clearEncounter();
ssdisplay.updateInfo(2, true);
check.equals(ldisplay[2].name, "map-status-clear");
ldisplay[0].shop = new Shop();
ssdisplay.updateInfo(2, true);
check.equals(ldisplay[2].name, "map-status-dockyard");
});
});