ConceptCreator/e2e/game-model/gamesystems/actions/AddActions.spec.ts

60 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-02-17 16:04:31 +01:00
import { test, expect } from '@playwright/test';
import {GamesystemTrainer} from "../GamesystemTrainer";
import {SimpleActionTrainer} from "./SimpleActionTrainer";
import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount";
import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction";
test.describe('Test Create SimpleActions', () => {
test('Test creating gamesystem with invalid name', async => {
const gameModel = GamesystemTrainer.givenEmptyGameModel();
let result = gameModel.createGamesystem(undefined, undefined);
expect(result).toBeUndefined();
result = gameModel.createGamesystem(null, undefined);
expect(result).toBeUndefined();
})
test("Adding invalid actions", async () => {
const transition = SimpleActionTrainer.withEmptyActions();
transition.addScriptAccountAction(null);
expect(transition.scriptAccountActions.length).toEqual(0);
transition.addScriptAccountAction(undefined);
expect(transition.scriptAccountActions.length).toEqual(0);
})
test("Adding not existing action", async () => {
const transition = SimpleActionTrainer.withEmptyActions();
const scriptAccount = new ScriptAccount("test", "");
const action = new ScriptAccountAction(scriptAccount, 10);
transition.addScriptAccountAction(action);
expect(transition.scriptAccountActions.length).toEqual(1);
expect(transition.scriptAccountActions[0].scriptAccount).toEqual(action.scriptAccount);
expect(transition.scriptAccountActions[0].changingValue).toEqual(10);
})
test("Adding existing action", async () => {
const transition = SimpleActionTrainer.withSingleAction();
const action = transition.scriptAccountActions[0];
transition.addScriptAccountAction(action);
expect(transition.scriptAccountActions.length).toEqual(1);
expect(transition.scriptAccountActions[0].changingValue).toEqual(20);
expect(transition.scriptAccountActions[0].scriptAccount).toEqual(action.scriptAccount);
})
test("Adding not existing action into non empty actions", async () => {
const transition = SimpleActionTrainer.withSingleAction();
const scriptAccount = new ScriptAccount("Tes", "");
transition.addScriptAccountAction(new ScriptAccountAction(scriptAccount, 10));
expect(transition.scriptAccountActions.length).toEqual(2);
})
});