import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; import {TranslateModule} from "@ngx-translate/core"; import {RouterTestingModule} from "@angular/router/testing"; import {ScriptAccountOverviewComponent} from "./script-account-overview.component"; import exp from "node:constants"; import {GameModel} from "../../game-model/GameModel"; describe('ScriptAccountOverview', () => { let component: ScriptAccountOverviewComponent; let fixture: ComponentFixture; beforeEach(waitForAsync(() => { void TestBed.configureTestingModule({ declarations: [ScriptAccountOverviewComponent], imports: [TranslateModule.forRoot(), RouterTestingModule] }).compileComponents(); fixture = TestBed.createComponent(ScriptAccountOverviewComponent); component = fixture.componentInstance; component.gameModel = new GameModel("GameModel") fixture.detectChanges(); })); it('should create', () => { expect(component).toBeTruthy(); }); it("Test ScriptAccount Creation", waitForAsync(() => { component.onCreateNewScriptAccount(); expect(component.gameModel!.scriptAccounts.length).toEqual(1) component.gameModel!.removeScriptAccount(component.gameModel!.scriptAccounts[0]); jest.spyOn(component.openScriptAccountEmitter, 'emit'); component.onCreateNewScriptAccount(); fixture.detectChanges(); expect(component.openScriptAccountEmitter.emit).toHaveBeenCalledWith(component.gameModel!.scriptAccounts[0]); component.onCreateNewScriptAccount(); fixture.detectChanges() expect(component.openScriptAccountEmitter.emit).toBeCalledTimes(1); })) });