diff --git a/Frontend/src/app/app.component.spec.ts b/Frontend/src/app/app.component.spec.ts
index 2cd7d9a..90f9657 100644
--- a/Frontend/src/app/app.component.spec.ts
+++ b/Frontend/src/app/app.component.spec.ts
@@ -11,19 +11,7 @@ describe('AppComponent', () => {
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
- expect(app).toBeTruthy();
+ expect(app).toBeDefined();
});
- it(`should have the 'Frontend' title`, () => {
- const fixture = TestBed.createComponent(AppComponent);
- const app = fixture.componentInstance;
- expect(app.title).toEqual('Frontend');
- });
-
- it('should render title', () => {
- const fixture = TestBed.createComponent(AppComponent);
- fixture.detectChanges();
- const compiled = fixture.nativeElement as HTMLElement;
- expect(compiled.querySelector('h1')?.textContent).toContain('Hello, Frontend');
- });
});
diff --git a/Frontend/src/app/chart/chart.component.spec.ts b/Frontend/src/app/chart/chart.component.spec.ts
index 94ee2aa..41946f1 100644
--- a/Frontend/src/app/chart/chart.component.spec.ts
+++ b/Frontend/src/app/chart/chart.component.spec.ts
@@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
-
import { ChartComponent } from './chart.component';
+import { ElementRef } from '@angular/core';
+import { CommonModule } from '@angular/common';
describe('ChartComponent', () => {
let component: ChartComponent;
@@ -8,10 +9,12 @@ describe('ChartComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
- imports: [ChartComponent]
- })
- .compileComponents();
-
+ imports: [ChartComponent,CommonModule],
+ providers: [{ provide: ElementRef, useValue: { nativeElement: {} } }]
+ }).compileComponents();
+ });
+
+ beforeEach(() => {
fixture = TestBed.createComponent(ChartComponent);
component = fixture.componentInstance;
fixture.detectChanges();
@@ -20,4 +23,43 @@ describe('ChartComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('set data', () => {
+ const data = [{ date: '2022-05-20', value: 50 }, { date: '2022-05-21', value: 60 }];
+ component.setData(data);
+ expect(component.getConfig().data.datasets[0].data).toEqual(data);
+ });
+
+ it('clear data', () => {
+ const initialData = [{ date: '2022-05-20', value: 50 }, { date: '2022-05-21', value: 60 }];
+ component.setData(initialData);
+ component.clearData();
+ expect(component.getConfig().data.datasets[0].data).toEqual([]);
+ });
+
+ it('set line color', () => {
+ const color = 'red';
+ component.setLineColor(color);
+ expect(component.getConfig().options.elements.line.borderColor).toBe(color);
+ });
+
+ it('set point color', () => {
+ const color = 'blue';
+ component.setPointColor(color);
+ expect(component.getConfig().options.elements.point.borderColor).toBe(color);
+ });
+
+ it('set min and max Y', () => {
+ const minValue = 0;
+ const maxValue = 100;
+ component.setMinY(minValue);
+ component.setMaxY(maxValue);
+ expect(component.getConfig().options.scales.y.min).toBe(minValue);
+ expect(component.getConfig().options.scales.y.max).toBe(maxValue);
+ });
+
+ it('getconfig test', () => {
+ const conf = component.getConfig();
+ expect(conf).toEqual(component.getConfig());
+ });
});
diff --git a/Frontend/src/app/dataset-graph/dataset-graph.component.html b/Frontend/src/app/dataset-graph/dataset-graph.component.html
index 2d5ccfc..c230a8c 100644
--- a/Frontend/src/app/dataset-graph/dataset-graph.component.html
+++ b/Frontend/src/app/dataset-graph/dataset-graph.component.html
@@ -3,7 +3,7 @@
trending_up
{{resourceName}}
-