ConceptCreator/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts
Sebastian Böckelmann d5f593a824
All checks were successful
E2E Testing / test (push) Successful in 1m24s
Datastructure for Gamesystems and Create and Remove SimpleStates and Transitions
2024-02-05 20:44:39 +01:00

105 lines
4.0 KiB
TypeScript

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";
test.describe('Test SimpleGamesystem', () => {
test("Create SimpleState", async () => {
const gamesystem = new SimpleGamesystem();
let state = gamesystem.createState("Test", "Test2");
expect(state.stateLabel).toEqual("Test");
expect(state.stateDescription).toEqual("Test2");
expect(state.incomingTransitions.length).toEqual(0);
expect(state.outgoingTransitions.length).toEqual(0);
expect(gamesystem.states.includes(state)).toBeTruthy();
state = gamesystem.createState(null, null);
expect(state).toBeUndefined();
expect(gamesystem.states.includes(state)).toBeFalsy();
state = gamesystem.createState(null, "test2");
expect(state).toBeUndefined()
expect(gamesystem.states.includes(state)).toBeFalsy();
state = gamesystem.createState("test2", null);
expect(state).toBeDefined();
expect(state.stateLabel).toEqual("test2");
expect(state.stateDescription).toEqual("");
expect(gamesystem.states.includes(state)).toBeTruthy();
state = gamesystem.createState(undefined, "State");
expect(state).toBeUndefined();
expect(gamesystem.states.includes(state)).toBeFalsy();
state = gamesystem.createState("Test3", undefined);
expect(state).toBeDefined();
expect(state.stateLabel).toEqual("Test3");
expect(state.stateDescription).toEqual("");
expect(gamesystem.states.includes(state)).toBeTruthy();
state = gamesystem.createState("", "");
expect(state).toBeDefined();
expect(state.stateLabel).toEqual("");
expect(state.stateDescription).toEqual("");
expect(gamesystem.states.includes(state)).toBeTruthy();
state = gamesystem.createState("Test3", "");
expect(state).toBeUndefined();
expect(gamesystem.states.includes(state)).toBeFalsy();
})
test("Create SimpleTransition", async () => {
const gamesystem = new SimpleGamesystem();
const startingState = gamesystem.createState("StartingState", "")!;
const endingState = gamesystem.createState("EndingState", "")!
let transition = gamesystem.createTransition(startingState, endingState);
expect(transition).toBeDefined();
expect(transition.startingState).toEqual(startingState);
expect(transition.endingState).toEqual(endingState);
expect(startingState.outgoingTransitions.includes(transition)).toBeTruthy();
expect(endingState.incomingTransitions.includes(transition)).toBeTruthy();
expect(gamesystem.transitions.includes(transition)).toBeTruthy();
transition = gamesystem.createTransition(null, null);
expect(transition).toBeUndefined();
transition = gamesystem.createTransition(null, endingState);
expect(transition).toBeUndefined();
transition = gamesystem.createTransition(undefined, undefined);
expect(transition).toBeUndefined();
transition = gamesystem.createTransition(undefined, endingState);
expect(transition).toBeUndefined();
transition = gamesystem.createTransition(startingState, null);
expect(transition).toBeUndefined();
transition = gamesystem.createTransition(startingState, undefined);
expect(transition).toBeUndefined();
transition = gamesystem.createTransition(startingState, startingState);
expect(transition).toBeUndefined();
transition = gamesystem.createTransition(startingState, endingState);
expect(transition).toBeUndefined();
})
test("Remove SimpleState", async () => {
})
test("Remove SimpleTransition", async () => {
})
});