56 lines
2.4 KiB
TypeScript
56 lines
2.4 KiB
TypeScript
|
|
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");
|
|
test.describe('Test Create Gamesystems', () => {
|
|
|
|
test("Test creation with null/undefined parameters", async () => {
|
|
let result = ScriptAccountCondition.constructScriptAccountCondition(null, 1, 2);
|
|
expect(result).toBeUndefined()
|
|
|
|
result = ScriptAccountCondition.constructScriptAccountCondition(undefined, 1, 2);
|
|
expect(result).toBeUndefined();
|
|
|
|
result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), null, 2);
|
|
expect(result).toBeUndefined();
|
|
|
|
result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), undefined, 2);
|
|
expect(result).toBeUndefined();
|
|
|
|
result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), 1, undefined);
|
|
expect(result).toBeUndefined();
|
|
|
|
result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""),1, null);
|
|
expect(result).toBeUndefined();
|
|
})
|
|
|
|
test("Test Creation with swapped Min Max Parameter", async () => {
|
|
let result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), 2, 1);
|
|
expect(result).toBeUndefined();
|
|
})
|
|
|
|
test("Test Correct Condition Creation", async () => {
|
|
const scriptAccount = new ScriptAccount("Test", "");
|
|
|
|
let result = ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 1, 2);
|
|
expect(result).toBeDefined();
|
|
expect(result!.scriptAccount).toEqual(scriptAccount)
|
|
expect(result!.minValue).toEqual(1);
|
|
expect(result!.maxValue).toEqual(2)
|
|
|
|
result = ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, -10, 2);
|
|
expect(result).toBeDefined();
|
|
expect(result!.scriptAccount).toEqual(scriptAccount)
|
|
expect(result!.minValue).toEqual(-10);
|
|
expect(result!.maxValue).toEqual(2)
|
|
|
|
result = ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, -20, -10);
|
|
expect(result).toBeDefined();
|
|
expect(result!.scriptAccount).toEqual(scriptAccount)
|
|
expect(result!.minValue).toEqual(-20);
|
|
expect(result!.maxValue).toEqual(-10)
|
|
})
|
|
|
|
});
|