ConceptCreator/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts

42 lines
2.0 KiB
TypeScript
Raw Normal View History

2024-02-17 19:06:38 +01:00
import { test, expect } from '@playwright/test';
import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition";
import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount";
import exp = require("node:constants");
import {ConditionTrainer} from "./ConditionTrainer";
import {Conditional} from "@angular/compiler";
import {TransitionConditionTrainer} from "./TransitionConditionTrainer";
import {transition} from "@angular/animations";
test.describe('Test Adding Conditions To Transitions', () => {
test("Test adding not contradicting Conditions", async () => {
const transition = TransitionConditionTrainer.withTransitionWithCondition();
const condition = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), -200, -100);
transition.addScriptAccountCondition(condition);
expect(transition.scriptAccountConditions.length).toEqual(2);
expect(transition.scriptAccountConditions.includes(condition)).toBeTruthy();
})
test("Test adding contradicting Conditions", async () => {
const transition = TransitionConditionTrainer.withTransitionWithCondition();
const condition = ConditionTrainer.withContradictingCondition(transition.scriptAccountConditions[0]);
transition.addScriptAccountCondition(condition)
expect(transition.scriptAccountConditions.length).toEqual(1);
expect(transition.scriptAccountConditions.includes(condition)).toBeFalsy();
})
test("Test expanding Conditions", async () => {
const transition = TransitionConditionTrainer.withTransitionWithCondition();
const condition = ConditionTrainer.withExpendingCondition(transition.scriptAccountConditions[0]);
transition.addScriptAccountCondition(condition);
expect(transition.scriptAccountConditions.length).toEqual(1);
expect(transition.scriptAccountConditions.includes(condition)).toBeFalsy();
expect(transition.scriptAccountConditions[0].minValue).toEqual(-10)
expect(transition.scriptAccountConditions[0].maxValue).toEqual(20)
})
});