Skip to content

Commit

Permalink
Working on the tests for the Fight component
Browse files Browse the repository at this point in the history
  • Loading branch information
dhAlcojor committed Aug 19, 2024
1 parent 8befa1c commit 55f5b89
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/app/fight/fight.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ describe('FightComponent', () => {

fixture = TestBed.createComponent(FightComponent)
component = fixture.componentInstance
fightEl = fixture.nativeElement
component.showDamage = () => {}
fixture.detectChanges()
})

it('should create', () => {
component.leftCharacterInitialHealth = 100
component.rightCharacterInitialHealth = 100
fixture.detectChanges()
component.ngOnInit()

const leftHealthBar = fightEl.querySelector(
'.left-health-bar',
Expand All @@ -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')
Expand All @@ -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)
})

0 comments on commit 55f5b89

Please sign in to comment.