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

51 lines
2.2 KiB
TypeScript
Raw Normal View History

2024-02-09 20:04:52 +01:00
import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright';
import { test, expect } from '@playwright/test';
import * as PATH from 'path';
import {GameModel} from "../../../src/app/game-model/GameModel";
import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem";
import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount";
import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType";
import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem";
import exp = require("node:constants");
import {end} from "electron-debug";
import {GamesystemTrainer} from "./GamesystemTrainer";
test.describe('Test Find Gamesystems', () => {
const GAMEMODELNAME: string = "GameModel";
const SIMPLEGAMESYSTEM_NAME: string = "Simple Gamesystem";
test('Find null or undefined Gamesystem', async () => {
const gameModel = new GameModel(GAMEMODELNAME);
expect(gameModel.findGamesystem(null)).toBeUndefined();
expect(gameModel.findGamesystem(undefined)).toBeUndefined();
})
test('Find non existend Gamesystem', async () => {
const gameModel = new GameModel(GAMEMODELNAME);
expect(gameModel.findGamesystem("Gamesystem")).toBeUndefined();
})
test("Find existend simple Gamesystem on top layer", async () => {
const gameModel = new GameModel(GAMEMODELNAME);
const gamesystem = new SimpleGamesystem(SIMPLEGAMESYSTEM_NAME);
gameModel.addGamesystem(gamesystem);
expect(gameModel.findGamesystem(SIMPLEGAMESYSTEM_NAME)).toBeDefined();
expect(gameModel.findGamesystem(SIMPLEGAMESYSTEM_NAME)).toEqual(gamesystem);
})
test('Find existent product gamesystem on top layer', async () => {
const gameModel = GamesystemTrainer.givenGameModelWithProductGamesytemOnTopLayer();
const result = gameModel.findGamesystem(GamesystemTrainer.TOP_PRODUCT_GAMESYSTEM_NAME);
expect(result).toBeDefined();
})
test('Find existent simple gamesystem on lower layer', async () => {
const gameModel = GamesystemTrainer.givenGameModelWithProductGamesytemOnTopLayer();
const result = gameModel.findGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEMNAME);
expect(result).toBeDefined();
})
});