74 lines
3.0 KiB
TypeScript
74 lines
3.0 KiB
TypeScript
import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright';
|
|
import { test, expect } from '@playwright/test';
|
|
import * as PATH from 'path';
|
|
import {GameModel} from "../../../src/app/game-model/GameModel";
|
|
import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem";
|
|
import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount";
|
|
import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType";
|
|
|
|
test.describe('Test ScriptAccounts', () => {
|
|
|
|
test("Test ScriptAccount Creation", async () => {
|
|
const scriptAccunt = new ScriptAccount("ScriptAccount", "Description");
|
|
|
|
expect(scriptAccunt.componentName).toEqual("ScriptAccount");
|
|
expect(scriptAccunt.componentDescription).toEqual("Description");
|
|
expect(scriptAccunt.type).toEqual(ModelComponentType.SCRIPTACCOUNT);
|
|
expect(scriptAccunt.minValue).toEqual(0);
|
|
expect(scriptAccunt.maxValue).toEqual(100);
|
|
})
|
|
|
|
test("Test Adding ScriptAccounts", async () => {
|
|
const gameModel: GameModel = new GameModel("GameModel");
|
|
|
|
const scriptAccount = new ScriptAccount("ScriptAccount", "Description");
|
|
gameModel.addScriptAccount(scriptAccount);
|
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
expect(gameModel.scriptAccounts.includes(scriptAccount)).toBeTruthy();
|
|
|
|
//Test for duplicates
|
|
gameModel.addScriptAccount(scriptAccount);
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
|
|
//Test for adding null value
|
|
gameModel.addScriptAccount(null);
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
gameModel.addScriptAccount(undefined);
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
|
|
//Test adding scriptAccount with already existing name
|
|
const scriptAccount2 = new ScriptAccount("ScriptAccount", "");
|
|
gameModel.addScriptAccount(scriptAccount2);
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
expect(gameModel.scriptAccounts.includes(scriptAccount2)).toBeFalsy();
|
|
})
|
|
|
|
test("test Removing ScriptAccounts", async () => {
|
|
const gameModel: GameModel = new GameModel("GameModel");
|
|
const scriptAccount = new ScriptAccount("ScriptAccount", "Description");
|
|
const scriptAccount2 = new ScriptAccount("ScriptAccount 2", "Description");
|
|
|
|
gameModel.removeScriptAccount(scriptAccount);
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
gameModel.addScriptAccount(scriptAccount);
|
|
gameModel.removeScriptAccount(scriptAccount);
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
gameModel.removeScriptAccount(undefined);
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
gameModel.removeScriptAccount(null);
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
gameModel.addScriptAccount(scriptAccount);
|
|
gameModel.addScriptAccount(scriptAccount2);
|
|
|
|
gameModel.removeScriptAccount(scriptAccount);
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
expect(gameModel.scriptAccounts.includes(scriptAccount2)).toBeTruthy();
|
|
})
|
|
|
|
});
|