From 55f5b89c41f76370a8eed103944b41ae8f933f40 Mon Sep 17 00:00:00 2001 From: "Daniel H. Alcojor" Date: Mon, 19 Aug 2024 14:47:16 +0200 Subject: [PATCH] Working on the tests for the Fight component --- src/app/fight/fight.component.spec.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app/fight/fight.component.spec.ts b/src/app/fight/fight.component.spec.ts index 8464ad3..fd36f3f 100644 --- a/src/app/fight/fight.component.spec.ts +++ b/src/app/fight/fight.component.spec.ts @@ -23,7 +23,7 @@ describe('FightComponent', () => { fixture = TestBed.createComponent(FightComponent) component = fixture.componentInstance - fightEl = fixture.nativeElement + component.showDamage = () => {} fixture.detectChanges() }) @@ -31,6 +31,7 @@ describe('FightComponent', () => { component.leftCharacterInitialHealth = 100 component.rightCharacterInitialHealth = 100 fixture.detectChanges() + component.ngOnInit() const leftHealthBar = fightEl.querySelector( '.left-health-bar', @@ -44,9 +45,10 @@ describe('FightComponent', () => { }) it('should reset the game', async () => { - component.leftCharacterInitialHealth = 100 - component.rightCharacterInitialHealth = 100 + component.leftCharacterInitialHealth = 200 + component.rightCharacterInitialHealth = 200 fixture.detectChanges() + component.ngOnInit() try { const resetButton = await waitFor('#resetButton') @@ -63,7 +65,7 @@ describe('FightComponent', () => { '.right-health-bar', ) as HTMLElement - expect(leftHealthBar.textContent).toContain('/ 100') - expect(rightHealthBar.textContent).toContain('/ 100') + expect(leftHealthBar.textContent).toContain('/ 200') + expect(rightHealthBar.textContent).toContain('/ 200') }, 30000) })