Skip to content

Commit

Permalink
Development: Remove deprecated router module in client tests (#9439)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWt authored Oct 8, 2024
1 parent 3779e88 commit b6b47e7
Show file tree
Hide file tree
Showing 71 changed files with 227 additions and 241 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { ArtemisTestModule } from '../../test.module';
import { MockComponent, MockDirective, MockModule, MockPipe, MockProvider } from 'ng-mocks';
import { ActivatedRoute, Router, convertToParamMap } from '@angular/router';
import { ActivatedRoute, Router, RouterModule, convertToParamMap } from '@angular/router';
import { of, throwError } from 'rxjs';
import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http';
import { SidePanelComponent } from 'app/shared/side-panel/side-panel.component';
Expand Down Expand Up @@ -57,7 +57,6 @@ import { MockTranslateValuesDirective } from '../../helpers/mocks/directive/mock
import { PieChartModule } from '@swimlane/ngx-charts';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service';
import { RouterTestingModule } from '@angular/router/testing';
import { SortService } from 'app/shared/service/sort.service';
import { ArtemisMarkdownService } from 'app/shared/markdown.service';
import { AccountService } from 'app/core/auth/account.service';
Expand Down Expand Up @@ -211,7 +210,7 @@ describe('ExerciseAssessmentDashboardComponent', () => {
}),
},
} as any as ActivatedRoute;
const imports = [ArtemisTestModule, RouterTestingModule.withRoutes([]), MockModule(PieChartModule)];
const imports = [ArtemisTestModule, MockModule(PieChartModule), RouterModule.forRoot([])];

const declarations = [
ExerciseAssessmentDashboardComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AssessmentHeaderComponent } from 'app/assessment/assessment-header/asse
import { ArtemisTestModule } from '../../test.module';
import { Result } from 'app/entities/result.model';
import { AlertOverlayComponent } from 'app/shared/alert/alert-overlay.component';
import { RouterTestingModule } from '@angular/router/testing';
import { AssessmentWarningComponent } from 'app/assessment/assessment-warning/assessment-warning.component';
import { MockProvider } from 'ng-mocks';
import { Exercise, ExerciseType } from 'app/entities/exercise.model';
Expand All @@ -25,6 +24,7 @@ import { MockTranslateValuesDirective } from '../../helpers/mocks/directive/mock
import { NgbTooltipMocksModule } from '../../helpers/mocks/directive/ngbTooltipMocks.module';
import { NgbAlertsMocksModule } from '../../helpers/mocks/directive/ngbAlertsMocks.module';
import { AssessmentNote } from 'app/entities/assessment-note.model';
import { RouterModule } from '@angular/router';

describe('AssessmentHeaderComponent', () => {
let component: AssessmentHeaderComponent;
Expand All @@ -49,7 +49,7 @@ describe('AssessmentHeaderComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterTestingModule, NgbTooltipMocksModule, NgbAlertsMocksModule],
imports: [ArtemisTestModule, NgbTooltipMocksModule, NgbAlertsMocksModule, RouterModule.forRoot([])],
declarations: [AssessmentHeaderComponent, AssessmentWarningComponent, AlertOverlayComponent, TranslateDirective, ArtemisTranslatePipe, MockTranslateValuesDirective],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { MockComponent, MockDirective, MockPipe, MockProvider } from 'ng-mocks';
import { of } from 'rxjs';
import { Competency, CompetencyRelation, CompetencyWithTailRelationDTO, CourseCompetencyProgress, CourseCompetencyType } from 'app/entities/competency.model';
import { CompetencyManagementComponent } from 'app/course/competencies/competency-management/competency-management.component';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, provideRouter } from '@angular/router';
import { DeleteButtonDirective } from 'app/shared/delete-dialog/delete-button.directive';
import { RouterTestingModule } from '@angular/router/testing';
import { TextUnit } from 'app/entities/lecture-unit/textUnit.model';
import { AccountService } from 'app/core/auth/account.service';
import { ArtemisTestModule } from '../../../test.module';
Expand Down Expand Up @@ -47,7 +46,7 @@ describe('CompetencyManagementComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterTestingModule.withRoutes([]), NgbProgressbar],
imports: [ArtemisTestModule, NgbProgressbar],
declarations: [
CompetencyManagementComponent,
MockHasAnyAuthorityDirective,
Expand All @@ -61,6 +60,7 @@ describe('CompetencyManagementComponent', () => {
MockDirective(DeleteButtonDirective),
],
providers: [
provideRouter([]),
MockProvider(AccountService),
MockProvider(AlertService),
{ provide: NgbModal, useClass: MockNgbModalService },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testin
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { MockComponent, MockPipe } from 'ng-mocks';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { RouterTestingModule } from '@angular/router/testing';
import { CompetenciesPopoverComponent } from 'app/course/competencies/competencies-popover/competencies-popover.component';
import { By } from '@angular/platform-browser';
import { Component } from '@angular/core';
import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
import { RouterModule } from '@angular/router';

@Component({
selector: 'jhi-statistics',
Expand All @@ -29,7 +29,7 @@ describe('CompetencyPopoverComponent', () => {
TestBed.configureTestingModule({
imports: [
NgbPopoverModule,
RouterTestingModule.withRoutes([
RouterModule.forRoot([
{ path: 'courses/:courseId/competencies', component: DummyStatisticsComponent },
{ path: 'course-management/:courseId/competency-management', component: DummyManagementComponent },
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor
import { ExerciseGroup } from 'app/entities/exercise-group.model';
import { TextareaCounterComponent } from 'app/shared/textarea/textarea-counter.component';
import { MockComponent, MockDirective, MockPipe, MockProvider } from 'ng-mocks';
import { RouterTestingModule } from '@angular/router/testing';
import { AlertService } from 'app/core/util/alert.service';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
Expand All @@ -18,6 +17,7 @@ import { of } from 'rxjs';
import { Course } from 'app/entities/course.model';
import { Exercise } from 'app/entities/exercise.model';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { provideRouter } from '@angular/router';

describe('ComplaintsForTutorComponent', () => {
let complaintsForTutorComponent: ComplaintsForTutorComponent;
Expand All @@ -29,15 +29,15 @@ describe('ComplaintsForTutorComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule.withRoutes([]), FormsModule],
imports: [FormsModule],
declarations: [
ComplaintsForTutorComponent,
MockPipe(ArtemisTranslatePipe),
MockPipe(ArtemisDatePipe),
MockComponent(TextareaCounterComponent),
MockDirective(TranslateDirective),
],
providers: [MockProvider(ComplaintResponseService), MockProvider(ComplaintService), MockProvider(AlertService)],
providers: [provideRouter([]), MockProvider(ComplaintResponseService), MockProvider(ComplaintService), MockProvider(AlertService)],
})
.compileComponents()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { of } from 'rxjs';
import { Course } from 'app/entities/course.model';
import { MockComponent, MockDirective, MockModule, MockPipe } from 'ng-mocks';
import { OrionFilterDirective } from 'app/shared/orion/orion-filter.directive';
import { RouterTestingModule } from '@angular/router/testing';
import { MockHasAnyAuthorityDirective } from '../../helpers/mocks/directive/mock-has-any-authority.directive';
import { TranslateService } from '@ngx-translate/core';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
Expand All @@ -15,7 +14,7 @@ import { CourseExercisesComponent } from 'app/overview/course-exercises/course-e
import { CourseExerciseRowComponent } from 'app/overview/course-exercises/course-exercise-row.component';
import { SidePanelComponent } from 'app/shared/side-panel/side-panel.component';
import { MockTranslateService, TranslatePipeMock } from '../../helpers/mocks/service/mock-translate.service';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, RouterModule } from '@angular/router';
import { ModelingExercise } from 'app/entities/modeling-exercise.model';
import { Exercise } from 'app/entities/exercise.model';
import dayjs from 'dayjs/esm';
Expand Down Expand Up @@ -45,7 +44,7 @@ describe('CourseExercisesComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, FormsModule, RouterTestingModule.withRoutes([]), MockModule(ReactiveFormsModule), MockDirective(TranslateDirective)],
imports: [ArtemisTestModule, FormsModule, RouterModule.forRoot([]), MockModule(ReactiveFormsModule), MockDirective(TranslateDirective)],
declarations: [
CourseExercisesComponent,
SidebarComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Course } from 'app/entities/course.model';
import { GuidedTourService } from 'app/guided-tour/guided-tour.service';
import { MockComponent, MockDirective, MockPipe, MockProvider } from 'ng-mocks';
import { OrionFilterDirective } from 'app/shared/orion/orion-filter.directive';
import { RouterTestingModule } from '@angular/router/testing';
import { MockHasAnyAuthorityDirective } from '../../helpers/mocks/directive/mock-has-any-authority.directive';
import { TranslateService } from '@ngx-translate/core';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
Expand All @@ -25,6 +24,7 @@ import { SortByDirective } from 'app/shared/sort/sort-by.directive';
import { SortDirective } from 'app/shared/sort/sort.directive';
import { DocumentationButtonComponent } from 'app/shared/components/documentation-button/documentation-button.component';
import { CourseAccessStorageService } from 'app/course/course-access-storage.service';
import { provideRouter } from '@angular/router';

describe('CourseManagementComponent', () => {
let fixture: ComponentFixture<CourseManagementComponent>;
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('CourseManagementComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterTestingModule.withRoutes([])],
imports: [ArtemisTestModule],
declarations: [
CourseManagementComponent,
MockDirective(OrionFilterDirective),
Expand All @@ -104,6 +104,7 @@ describe('CourseManagementComponent', () => {
MockComponent(DocumentationButtonComponent),
],
providers: [
provideRouter([]),
{ provide: LocalStorageService, useClass: MockSyncStorage },
{ provide: SessionStorageService, useClass: MockSyncStorage },
MockProvider(TranslateService),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testin
import { CourseManagementService } from 'app/course/manage/course-management.service';
import { ArtemisTestModule } from '../../test.module';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { ActivatedRoute, Params, Router, RouterModule } from '@angular/router';
import { Course, CourseInformationSharingConfiguration } from 'app/entities/course.model';
import { MockComponent, MockDirective, MockModule, MockPipe, MockProvider } from 'ng-mocks';
import { RouterTestingModule } from '@angular/router/testing';
import { MockHasAnyAuthorityDirective } from '../../helpers/mocks/directive/mock-has-any-authority.directive';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
import { CourseExerciseRowComponent } from 'app/overview/course-exercises/course-exercise-row.component';
Expand Down Expand Up @@ -165,8 +164,8 @@ describe('CourseOverviewComponent', () => {

TestBed.configureTestingModule({
imports: [
RouterModule.forRoot([]),
ArtemisTestModule,
RouterTestingModule.withRoutes([]),
MockModule(MatSidenavModule),
MockModule(NgbTooltipModule),
MockModule(BrowserAnimationsModule),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ArtemisTestModule } from '../../../test.module';
import { MockSyncStorage } from '../../../helpers/mocks/service/mock-sync-storage.service';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import { MockComponent, MockDirective, MockPipe } from 'ng-mocks';
import { RouterTestingModule } from '@angular/router/testing';
import { MockHasAnyAuthorityDirective } from '../../../helpers/mocks/directive/mock-has-any-authority.directive';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
Expand All @@ -15,6 +14,7 @@ import { of } from 'rxjs';
import { StatisticsAverageScoreGraphComponent } from 'app/shared/statistics-graph/statistics-average-score-graph.component';
import { ExerciseType } from 'app/entities/exercise.model';
import { DocumentationButtonComponent } from 'app/shared/components/documentation-button/documentation-button.component';
import { RouterModule } from '@angular/router';

describe('CourseManagementStatisticsComponent', () => {
let fixture: ComponentFixture<CourseManagementStatisticsComponent>;
Expand All @@ -31,7 +31,7 @@ describe('CourseManagementStatisticsComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterTestingModule.withRoutes([])],
imports: [ArtemisTestModule, RouterModule.forRoot([])],
declarations: [
CourseManagementStatisticsComponent,
MockComponent(StatisticsGraphComponent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import { By } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
import { Router } from '@angular/router';
import { Router, provideRouter } from '@angular/router';

describe('CourseRegistrationButtonComponent', () => {
let fixture: ComponentFixture<CourseUnenrollmentModalComponent>;
Expand All @@ -29,9 +28,9 @@ describe('CourseRegistrationButtonComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, ReactiveFormsModule, RouterTestingModule.withRoutes([])],
imports: [ArtemisTestModule, ReactiveFormsModule],
declarations: [CourseUnenrollmentModalComponent, MockPipe(ArtemisTranslatePipe), MockPipe(ArtemisDatePipe)],
providers: [MockProvider(CourseManagementService), MockProvider(AlertService), MockProvider(TranslateService)],
providers: [provideRouter([]), MockProvider(CourseManagementService), MockProvider(AlertService), MockProvider(TranslateService)],
})
.compileComponents()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { HttpTestingController } from '@angular/common/http/testing';
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
import { Location } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateService } from '@ngx-translate/core';
import { DueDateStat } from 'app/course/dashboards/due-date-stat.model';
import { CourseForDashboardDTO } from 'app/course/manage/course-for-dashboard-dto';
Expand Down Expand Up @@ -93,7 +92,7 @@ describe('CoursesComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterTestingModule.withRoutes([{ path: 'courses/:courseId/exams/:examId', component: DummyComponent }])],
imports: [ArtemisTestModule, RouterModule.forRoot([{ path: 'courses/:courseId/exams/:examId', component: DummyComponent }])],
declarations: [
CoursesComponent,
MockDirective(MockHasAnyAuthorityDirective),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { RouterTestingModule } from '@angular/router/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ArtemisTestModule } from '../../../test.module';
import { CourseDetailDoughnutChartComponent } from 'app/course/manage/detail/course-detail-doughnut-chart.component';
Expand All @@ -7,6 +6,7 @@ import { MockModule, MockPipe } from 'ng-mocks';
import { DoughnutChartType } from 'app/course/manage/detail/course-detail.component';
import { Course } from 'app/entities/course.model';
import { PieChartModule } from '@swimlane/ngx-charts';
import { provideRouter } from '@angular/router';

describe('CourseDetailDoughnutChartComponent', () => {
let fixture: ComponentFixture<CourseDetailDoughnutChartComponent>;
Expand All @@ -19,8 +19,9 @@ describe('CourseDetailDoughnutChartComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterTestingModule.withRoutes([]), MockModule(PieChartModule)],
imports: [ArtemisTestModule, MockModule(PieChartModule)],
declarations: [CourseDetailDoughnutChartComponent, MockPipe(ArtemisTranslatePipe)],
providers: [provideRouter([])],
})
.compileComponents()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateService } from '@ngx-translate/core';
import { MockDirective, MockModule, MockPipe, MockProvider } from 'ng-mocks';
import { of } from 'rxjs';
Expand All @@ -16,6 +15,7 @@ import { NgxChartsSingleSeriesDataEntry } from 'app/shared/chart/ngx-charts-data
import { ExerciseType } from 'app/entities/exercise.model';
import { LocaleConversionService } from 'app/shared/service/locale-conversion.service';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { RouterModule } from '@angular/router';

describe('ExamScoresAverageScoresGraphComponent', () => {
let fixture: ComponentFixture<ExamScoresAverageScoresGraphComponent>;
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('ExamScoresAverageScoresGraphComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterTestingModule.withRoutes([]), MockModule(BarChartModule)],
imports: [ArtemisTestModule, MockModule(BarChartModule), RouterModule.forRoot([])],
declarations: [ExamScoresAverageScoresGraphComponent, MockPipe(ArtemisTranslatePipe), MockDirective(TranslateDirective)],
providers: [
MockProvider(CourseManagementService, {
Expand Down
Loading

0 comments on commit b6b47e7

Please sign in to comment.