ConceptCreator/e2e/game-model/gamesystems/CreateGamesystem.spec.ts

45 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-02-10 10:11:07 +01:00
import { test, expect } from '@playwright/test';
import {GamesystemTrainer} from "./GamesystemTrainer";
import {ProductGamesystem} from "../../../src/app/project/game-model/gamesystems/ProductGamesystem";
2024-02-10 10:11:07 +01:00
test.describe('Test Create Gamesystems', () => {
test('Test creating gamesystem with invalid name', async => {
const gameModel = GamesystemTrainer.givenEmptyGameModel();
let result = gameModel.createGamesystem(undefined, undefined);
expect(result).toBeUndefined();
result = gameModel.createGamesystem(null, undefined);
expect(result).toBeUndefined();
})
test("Test creating gamesystem with valid name but without parent", async => {
const gameModel = GamesystemTrainer.givenEmptyGameModel();
let result = gameModel.createGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEMNAME, undefined);
expect(result).toBeDefined();
expect(gameModel.gamesystems.length).toEqual(1);
expect(gameModel.findGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEMNAME)).toBeDefined();
})
test("Test creating Gamesystem with valid name but with Product Parent", async => {
const gameModel = GamesystemTrainer.givenGameModelWithProductGamesytemOnTopLayer();
let result = gameModel.createGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEM_LEAF_LEFT, GamesystemTrainer.TOP_PRODUCT_GAMESYSTEM_NAME);
expect(result).toBeDefined();
expect(result.parentGamesystem!.componentName).toEqual(GamesystemTrainer.TOP_PRODUCT_GAMESYSTEM_NAME);
expect(result.parentGamesystem!.innerGamesystems.length).toEqual(3);
expect(result.parentGamesystem!.innerGamesystems.includes(result)).toBeTruthy();
})
test("Test creating Gamesystem with valid name but with Simple Parent", async() => {
const gameModel = GamesystemTrainer.givenGameModelWithSimpleGamesystemOnTopLayer();
let result = gameModel.createGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEM_LEAF_LEFT, GamesystemTrainer.SIMPLEGAMESYSTEMNAME);
expect(result).toBeDefined();
expect(gameModel.gamesystems.length).toEqual(1);
expect(gameModel.gamesystems[0]).toBeInstanceOf(ProductGamesystem);
expect(gameModel.gamesystems[0]).toEqual(result.parentGamesystem);
expect((gameModel.gamesystems[0] as ProductGamesystem).innerGamesystems.length).toEqual(1);
expect((gameModel.gamesystems[0] as ProductGamesystem).innerGamesystems.includes(result)).toBeTruthy();
})
});