1
0
Fork 0
spacetac/src/ui/character/FleetCreationView.spec.ts

37 lines
2.0 KiB
TypeScript

module TK.SpaceTac.UI.Specs {
testing("FleetCreationView", test => {
let testgame = setupSingleView(test, () => [new FleetCreationView({}), []]);
test.acase("validates the fleet creation", async check => {
let mock_router = check.patch(testgame.view, "backToRouter");
check.same(testgame.ui.session.isFleetCreated(), false, "no fleet created");
check.same(testgame.ui.session.player.fleet.ships.length, 0, "empty session fleet");
check.same(testgame.view.dialogs_layer.length, 0, "no dialogs");
check.same(testgame.view.character_sheet.fleet, testgame.view.built_fleet);
check.same(testgame.view.built_fleet.ships.length, 2, "initial fleet should have two ships");
// close sheet
testClick(testgame.view.character_sheet.close_button);
check.same(testgame.view.dialogs_opened.length, 1, "confirmation dialog opened");
check.same(testgame.ui.session.isFleetCreated(), false, "still no fleet created");
// click on no in confirmation dialog
let dialog = <UIConfirmDialog>testgame.view.dialogs_opened[0];
await dialog.forceResult(false);
check.same(testgame.view.dialogs_opened.length, 0, "confirmation dialog destroyed after 'no'");
check.same(testgame.ui.session.isFleetCreated(), false, "still no fleet created after 'no'");
check.called(mock_router, 0);
// close sheet, click on yes in confirmation dialog
testClick(testgame.view.character_sheet.close_button);
dialog = <UIConfirmDialog>testgame.view.dialogs_opened[0];
await dialog.forceResult(true);
check.same(testgame.view.dialogs_opened.length, 0, "confirmation dialog destroyed after 'yes'");
check.same(testgame.ui.session.isFleetCreated(), true, "fleet created");
check.same(testgame.ui.session.player.fleet.ships.length, 2, "session fleet now has two ships");
check.called(mock_router, 1);
})
})
}