style(frontend): applique prettier aux fichiers du tableau de bord
Les onze fichiers non conformes au .prettierrc du projet etaient exactement ceux introduits ou modifies par cette branche ; les vingt-deux autres du frontend etaient deja propres. Aucune modification de comportement : indentation, virgules finales et longueur de ligne a 100 caracteres.
This commit is contained in:
@@ -32,17 +32,17 @@ describe('ConsumptionGauge', () => {
|
||||
expect(() => fixture.detectChanges()).not.toThrow();
|
||||
});
|
||||
it('met à jour le graphique quand les valeurs changent après initialisation', () => {
|
||||
TestBed.configureTestingModule({ imports: [ConsumptionGauge] });
|
||||
const fixture = TestBed.createComponent(ConsumptionGauge);
|
||||
fixture.componentRef.setInput('consumption', 300);
|
||||
fixture.componentRef.setInput('capacity', 1000);
|
||||
fixture.detectChanges(); // déclenche ngAfterViewInit, this.chart existe désormais
|
||||
TestBed.configureTestingModule({ imports: [ConsumptionGauge] });
|
||||
const fixture = TestBed.createComponent(ConsumptionGauge);
|
||||
fixture.componentRef.setInput('consumption', 300);
|
||||
fixture.componentRef.setInput('capacity', 1000);
|
||||
fixture.detectChanges(); // déclenche ngAfterViewInit, this.chart existe désormais
|
||||
|
||||
fixture.componentRef.setInput('consumption', 500);
|
||||
fixture.detectChanges(); // ré-exécute l'effect, cette fois avec this.chart défini
|
||||
fixture.componentRef.setInput('consumption', 500);
|
||||
fixture.detectChanges(); // ré-exécute l'effect, cette fois avec this.chart défini
|
||||
|
||||
expect(() => fixture.detectChanges()).not.toThrow();
|
||||
});
|
||||
expect(() => fixture.detectChanges()).not.toThrow();
|
||||
});
|
||||
|
||||
it('détruit le graphique quand le composant est détruit', () => {
|
||||
TestBed.configureTestingModule({ imports: [ConsumptionGauge] });
|
||||
|
||||
@@ -28,25 +28,46 @@ describe('SiteLoadChart', () => {
|
||||
TestBed.configureTestingModule({ imports: [SiteLoadChart] });
|
||||
const fixture = TestBed.createComponent(SiteLoadChart);
|
||||
fixture.componentRef.setInput('sites', [
|
||||
{ site_id: 'S1', site_name: 'Test', current_consumption_kw: 50, capacity_kw: 100, load_percent: 50, data_quality: 'good' },
|
||||
{
|
||||
site_id: 'S1',
|
||||
site_name: 'Test',
|
||||
current_consumption_kw: 50,
|
||||
capacity_kw: 100,
|
||||
load_percent: 50,
|
||||
data_quality: 'good',
|
||||
},
|
||||
]);
|
||||
expect(() => fixture.detectChanges()).not.toThrow();
|
||||
});
|
||||
it('met à jour le graphique quand les sites changent après initialisation', () => {
|
||||
TestBed.configureTestingModule({ imports: [SiteLoadChart] });
|
||||
const fixture = TestBed.createComponent(SiteLoadChart);
|
||||
fixture.componentRef.setInput('sites', [
|
||||
{ site_id: 'S1', site_name: 'A', current_consumption_kw: 50, capacity_kw: 100, load_percent: 50, data_quality: 'good' },
|
||||
]);
|
||||
fixture.detectChanges(); // déclenche ngAfterViewInit, this.chart existe désormais
|
||||
TestBed.configureTestingModule({ imports: [SiteLoadChart] });
|
||||
const fixture = TestBed.createComponent(SiteLoadChart);
|
||||
fixture.componentRef.setInput('sites', [
|
||||
{
|
||||
site_id: 'S1',
|
||||
site_name: 'A',
|
||||
current_consumption_kw: 50,
|
||||
capacity_kw: 100,
|
||||
load_percent: 50,
|
||||
data_quality: 'good',
|
||||
},
|
||||
]);
|
||||
fixture.detectChanges(); // déclenche ngAfterViewInit, this.chart existe désormais
|
||||
|
||||
fixture.componentRef.setInput('sites', [
|
||||
{ site_id: 'S2', site_name: 'B', current_consumption_kw: 80, capacity_kw: 100, load_percent: 80, data_quality: 'critical' },
|
||||
]);
|
||||
fixture.detectChanges(); // ré-exécute l'effect, cette fois avec this.chart défini
|
||||
fixture.componentRef.setInput('sites', [
|
||||
{
|
||||
site_id: 'S2',
|
||||
site_name: 'B',
|
||||
current_consumption_kw: 80,
|
||||
capacity_kw: 100,
|
||||
load_percent: 80,
|
||||
data_quality: 'critical',
|
||||
},
|
||||
]);
|
||||
fixture.detectChanges(); // ré-exécute l'effect, cette fois avec this.chart défini
|
||||
|
||||
expect(() => fixture.detectChanges()).not.toThrow();
|
||||
});
|
||||
expect(() => fixture.detectChanges()).not.toThrow();
|
||||
});
|
||||
|
||||
it('détruit le graphique quand le composant est détruit', () => {
|
||||
TestBed.configureTestingModule({ imports: [SiteLoadChart] });
|
||||
|
||||
@@ -37,7 +37,9 @@ export class SiteLoadChart implements AfterViewInit, OnDestroy {
|
||||
if (this.chart) {
|
||||
this.chart.data.labels = sites.map((s) => s.site_name);
|
||||
this.chart.data.datasets[0].data = sites.map((s) => s.load_percent ?? 0);
|
||||
this.chart.data.datasets[0].backgroundColor = sites.map((s) => QUALITY_COLORS[s.data_quality]);
|
||||
this.chart.data.datasets[0].backgroundColor = sites.map(
|
||||
(s) => QUALITY_COLORS[s.data_quality],
|
||||
);
|
||||
this.chart.update('none');
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user