fix: Fixed test units

This commit is contained in:
2025-06-04 16:24:18 +02:00
parent 9f97e584bd
commit c525dfe1c1
39 changed files with 632 additions and 82 deletions

View File

@@ -1,14 +1,55 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { GradesComponent } from './grades.component';
import { AdminCommService } from '../admin-comm.service';
import { RouterModule } from '@angular/router';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import * as moment from 'moment';
import { MatIconModule } from '@angular/material/icon';
import { MatFormFieldModule } from '@angular/material/form-field';
import { of } from 'rxjs';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@Component({selector: "app-date-selector", template: ''})
class DateSelectorStub {
@Input() date: moment.Moment = moment.utc().startOf('day');
@Output() dateChange = new EventEmitter<moment.Moment>();
@Input() filter: (date: moment.Moment | null) => boolean = () => true
}
@Component({selector: "app-room-chooser", template: ''})
class RoomSelectorStub {
@Input() rooms: string[] = []
@Output() room: EventEmitter<string> = new EventEmitter<string>();
}
describe('GradesComponent', () => {
let component: GradesComponent;
let fixture: ComponentFixture<GradesComponent>;
let acMock
beforeEach(async () => {
acMock = {
clean: {
getConfig: jasmine.createSpy("getConfig").and.returnValue(of())
}
}
await TestBed.configureTestingModule({
imports: [GradesComponent]
declarations: [GradesComponent, DateSelectorStub, RoomSelectorStub],
providers: [
{provide: AdminCommService, useValue: acMock}
],
imports: [
RouterModule.forRoot([]),
MatIconModule,
MatFormFieldModule,
FormsModule,
ReactiveFormsModule,
MatInputModule,
NoopAnimationsModule
]
})
.compileComponents();