Skip to content

Commit

Permalink
ajout de TU
Browse files Browse the repository at this point in the history
  • Loading branch information
abarhub committed Feb 18, 2024
1 parent 165ed51 commit c06a863
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import {
ComponentFixture,
TestBed,
tick,
waitForAsync,
} from '@angular/core/testing';

import { SelectionChiffresComponent } from './selection-chiffres.component';
import { JeuxService } from '../../service/jeux.service';
import { NiveauDifficulteEnum } from '../../models/niveau-difficulte.enum';

describe('SelectionChiffresComponent', () => {
let component: SelectionChiffresComponent;
let fixture: ComponentFixture<SelectionChiffresComponent>;
let jeuxService: JeuxService;
let fixture2: ComponentFixture<JeuxService>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
Expand All @@ -15,10 +24,42 @@ describe('SelectionChiffresComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(SelectionChiffresComponent);
component = fixture.componentInstance;
jeuxService = TestBed.inject(JeuxService);
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should create new grid', waitForAsync(() => {
// ARRANGE

// ACT
jeuxService.nouvelleGrille(NiveauDifficulteEnum.FACILE);

// ASSERT
expect(component).toBeTruthy();
expect(component.nbRestant).toBeTruthy();
expect(component.nbRestant.find(value => value > 0))
.withContext('there is one greater than 0')
.toBeTruthy();
}));

it('should select number', waitForAsync(() => {
// ARRANGE
jeuxService.nouvelleGrille(NiveauDifficulteEnum.FACILE);
component.remplissageAutoChiffre = true;

// ACT
component.selectionChiffre(5);

// ASSERT
expect(component).toBeTruthy();
expect(component.chiffreSelectionnee).toEqual(5);
expect(component.estSelectionne(5)).toBeTrue();
expect(component.nbRestant.find(value => value > 0))
.withContext('there is one greater than 0')
.toBeTruthy();
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class SelectionChiffresComponent implements OnInit, OnDestroy {
for (let i = 0; i < 9; i++) {
this.nbRestant[i] = Math.max(9 - tab[i], 0);
}
console.log('tab', tab, 'nbRestant', this.nbRestant);
}

nombreRestant(chiffre: number): number {
Expand Down

0 comments on commit c06a863

Please sign in to comment.