ConceptCreator/e2e/game-model/gamesystems/conditions/ConditionContradicting.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

44 lines
2.2 KiB
TypeScript

import { test, expect } from '@playwright/test';
import {ScriptAccountCondition} from "../../../../src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition";
import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount";
import exp = require("node:constants");
import {ConditionTrainer} from "./ConditionTrainer";
import {Conditional} from "@angular/compiler";
test.describe('Test Contradicting Conditions', () => {
test("Test contradicting conditions", async () => {
const condition = ConditionTrainer.withSimpleCondition();
let contradictingCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.maxValue + 10, condition.maxValue+200);
expect(condition.isContradicting(contradictingCondition)).toBeTruthy();
contradictingCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-100, condition.minValue-50);
expect(condition.isContradicting(contradictingCondition)).toBeTruthy();
})
test("Test intersecting conditions", async () => {
const condition = ConditionTrainer.withSimpleCondition();
let otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-1, condition.minValue+1);
expect(condition.isContradicting(otherCondition)).toBeFalsy();
otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.maxValue-1, condition.maxValue+1);
expect(condition.isContradicting(otherCondition)).toBeFalsy();
otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-1, condition.maxValue+1);
expect(condition.isContradicting(otherCondition)).toBeFalsy();
expect(condition.isContradicting(condition)).toBeFalsy();
})
test("Test contradicting conditions with different ScriptAccount", async () => {
const condition = ConditionTrainer.withSimpleCondition();
const otherCondition = ScriptAccountCondition.constructScriptAccountCondition(
new ScriptAccount("Another test", ""), condition.minValue-20, condition.minValue-10);
expect(condition.isContradicting(otherCondition)).toBeFalsy();
})
});