ConceptCreator/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts
Sebastian Böckelmann 75815578dc
Some checks failed
E2E Testing / test (push) Failing after 1m39s
Fix typo in gamemodel import path in test
2024-03-22 08:10:22 +01:00

52 lines
2.9 KiB
TypeScript

import { test, expect } from '@playwright/test';
import {ProductStateTrainer} from "./ProductStateTrainer";
import {ProductState} from "../../../../src/app/project/game-model/gamesystems/states/ProductState";
import {SimpleGamesystem} from "../../../../src/app/project/game-model/gamesystems/SimpleGamesystem";
test.describe('Test Create ProductTransitions', () => {
test("Test ProductTransition Creation with invalid inputs", async ()=> {
const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates();
expect(gamesystem.createTransition(null, null)).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
expect(gamesystem.createTransition(undefined, undefined)).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
expect(gamesystem.createTransition(undefined, gamesystem.states[0])).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
expect(gamesystem.createTransition(null, gamesystem.states[0])).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
expect(gamesystem.createTransition(gamesystem.states[0], undefined)).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
expect(gamesystem.createTransition(gamesystem.states[0], null)).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
})
test("Test ProductTransitition Creation with duplicate Transition", async ()=> {
const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates();
expect(gamesystem.createTransition(gamesystem.states[0], gamesystem.states[1])).toBeUndefined();
})
test("Test ProductTransition Creation with foreign States", async () => {
const simpleGamesystems: SimpleGamesystem[] = [new SimpleGamesystem("Test", "Test"), new SimpleGamesystem("Test1", "Test2")];
const simpleGamesystem2: SimpleGamesystem[] = [new SimpleGamesystem("Test3", "Test"), new SimpleGamesystem("Test4", "Test2")];
const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates();
const foreignProductState = new ProductState(simpleGamesystems);
const foreignEndProductState = new ProductState(simpleGamesystem2);
expect(gamesystem.createTransition(foreignProductState, foreignEndProductState)).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
})
test("Test creating SelfTransitions", async ()=> {
const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates();
expect(gamesystem.createTransition(gamesystem.states[0], gamesystem.states[0])).toBeUndefined();
expect(gamesystem.transitions.length).toEqual(3);
})
test("Test Valid Transition Creation", async () => {
const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates();
expect(gamesystem.createTransition(gamesystem.states[1], gamesystem.states[2])).toBeDefined();
expect(gamesystem.transitions.length).toEqual(4)
})
});