Skip to content

Commit

Permalink
Development: Remove HttpClientTestingModule as it is deprecated (#9435)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWt authored Oct 7, 2024
1 parent 1b12f3e commit 3779e88
Show file tree
Hide file tree
Showing 147 changed files with 692 additions and 428 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { of } from 'rxjs';
import { ConfigurationComponent } from 'app/admin/configuration/configuration.component';
import { ConfigurationService } from 'app/admin/configuration/configuration.service';
import { Bean, PropertySource } from 'app/admin/configuration/configuration.model';
import { provideHttpClient } from '@angular/common/http';

describe('Component Tests', () => {
describe('ConfigurationComponent', () => {
Expand All @@ -13,9 +14,9 @@ describe('Component Tests', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
declarations: [ConfigurationComponent],
providers: [ConfigurationService],
providers: [provideHttpClient(), provideHttpClientTesting(), ConfigurationService],
})
.overrideTemplate(ConfigurationComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';

import { LegalDocumentService } from 'app/shared/service/legal-document.service';
import { LegalDocument, LegalDocumentLanguage, LegalDocumentType } from 'app/entities/legal-document.model';
import { PrivacyStatement } from 'app/entities/privacy-statement.model';
import { Imprint } from 'app/entities/imprint.model';
import { provideHttpClient } from '@angular/common/http';

describe('LegalDocumentService', () => {
let service: LegalDocumentService;
let httpMock: HttpTestingController;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
providers: [provideHttpClient(), provideHttpClientTesting()],
});
service = TestBed.inject(LegalDocumentService);
httpMock = TestBed.inject(HttpTestingController);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { of } from 'rxjs';

import { LogsComponent } from 'app/admin/logs/logs.component';
import { LogsService } from 'app/admin/logs/logs.service';
import { Log, LoggersResponse } from 'app/admin/logs/log.model';
import { provideHttpClient } from '@angular/common/http';

describe('Component Tests', () => {
describe('LogsComponent', () => {
Expand All @@ -14,9 +15,9 @@ describe('Component Tests', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
declarations: [LogsComponent],
providers: [LogsService],
providers: [provideHttpClient(), provideHttpClientTesting(), LogsService],
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { AccountService } from 'app/core/auth/account.service';
import { MockAccountService } from '../../helpers/mocks/service/mock-account.service';
import { ActivatedRoute, Router } from '@angular/router';
import { HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
import { HttpHeaders, HttpParams, HttpResponse, provideHttpClient } from '@angular/common/http';
import { User } from 'app/core/user/user.model';
import { Subscription, of } from 'rxjs';
import { AbstractControl, ReactiveFormsModule } from '@angular/forms';
Expand All @@ -25,7 +25,7 @@ import { ArtemisTestModule } from '../../test.module';
import { MockRouter } from '../../helpers/mocks/mock-router';
import { MockRouterLinkDirective } from '../../helpers/mocks/directive/mock-router-link.directive';
import { EventManager } from 'app/core/util/event-manager.service';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { CourseManagementService } from 'app/course/manage/course-management.service';
import { MockLocalStorageService } from '../../helpers/mocks/service/mock-local-storage.service';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('UserManagementComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, MockModule(ReactiveFormsModule), MockModule(NgbModule), HttpClientTestingModule],
imports: [ArtemisTestModule, MockModule(ReactiveFormsModule), MockModule(NgbModule)],
declarations: [
UserManagementComponent,
MockRouterLinkDirective,
Expand All @@ -73,6 +73,8 @@ describe('UserManagementComponent', () => {
MockDirective(SortDirective),
],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
{
provide: ActivatedRoute,
useValue: route,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testin
import { Router } from '@angular/router';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { ApollonDiagram } from 'app/entities/apollon-diagram.model';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { TranslateService } from '@ngx-translate/core';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import { ApollonDiagramCreateFormComponent } from 'app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-create-form.component';
import { ApollonDiagramService } from 'app/exercises/quiz/manage/apollon-diagrams/apollon-diagram.service';
import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service';
import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service';
import { MockRouter } from '../../helpers/mocks/mock-router';
import { HttpResponse } from '@angular/common/http';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { of } from 'rxjs';
import { UMLDiagramType } from '@ls1intum/apollon';

Expand All @@ -25,9 +25,11 @@ describe('ApollonDiagramCreateForm Component', () => {
diagram.id = 1;

TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
declarations: [ApollonDiagramCreateFormComponent],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
ApollonDiagramService,
NgbActiveModal,
{ provide: SessionStorageService, useClass: MockSyncStorage },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { AlertService } from 'app/core/util/alert.service';
import { SortService } from 'app/shared/service/sort.service';
import { ApollonDiagramListComponent } from 'app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component';
import { ApollonDiagram } from 'app/entities/apollon-diagram.model';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { HttpResponse } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { CourseManagementService } from 'app/course/manage/course-management.service';
import { AccountService } from 'app/core/auth/account.service';
import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service';
Expand All @@ -31,9 +31,11 @@ describe('ApollonDiagramList Component', () => {
const route = { params: of({ courseId: 123 }), snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any as ActivatedRoute;

TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
declarations: [ApollonDiagramListComponent],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
AlertService,
ApollonDiagramService,
MockProvider(SortService),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { Selection, UMLModel, UMLModelElement, findElement } from '@ls1intum/apollon';
Expand Down Expand Up @@ -40,9 +40,11 @@ describe('QuizExercise Generator', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
declarations: [],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
MockProvider(TranslateService),
{
provide: SessionStorageService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import { of } from 'rxjs';
import { CourseManagementService } from 'app/course/manage/course-management.service';
import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route';
import { ActivatedRoute } from '@angular/router';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { ExamManagementService } from 'app/exam/manage/exam-management.service';
import { provideHttpClient } from '@angular/common/http';

describe('AssessmentLocksComponent', () => {
let component: AssessmentLocksComponent;
Expand All @@ -39,9 +40,11 @@ describe('AssessmentLocksComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
imports: [TranslateModule.forRoot()],
declarations: [AssessmentLocksComponent, MockPipe(ArtemisTranslatePipe), MockRouterLinkDirective, MockHasAnyAuthorityDirective, MockPipe(ArtemisDatePipe)],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
MockProvider(TextAssessmentService),
MockProvider(CourseManagementService),
MockProvider(ModelingAssessmentService),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { LectureUnitService } from 'app/lecture/lecture-unit/lecture-unit-management/lectureUnit.service';
import { MockProvider } from 'ng-mocks';
Expand Down Expand Up @@ -43,8 +43,10 @@ describe('CompetencyService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
MockProvider(LectureUnitService, {
convertLectureUnitArrayDatesFromServer<T extends LectureUnit>(res: T[]): T[] {
return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { Competency, CompetencyProgress, CourseCompetencyType } from 'app/entiti
import { ActivatedRoute } from '@angular/router';
import { AlertService } from 'app/core/util/alert.service';
import { CourseCompetenciesComponent } from 'app/overview/course-competencies/course-competencies.component';
import { HttpResponse } from '@angular/common/http';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { TextUnit } from 'app/entities/lecture-unit/textUnit.model';
import { AccountService } from 'app/core/auth/account.service';
import { User } from 'app/core/user/user.model';
import { CourseStorageService } from 'app/course/manage/course-storage.service';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { ArtemisTestModule } from '../../test.module';
import { CompetencyCardStubComponent } from './competency-card-stub.component';
import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service';
Expand Down Expand Up @@ -50,9 +50,11 @@ describe('CourseCompetencies', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, HttpClientTestingModule],
imports: [ArtemisTestModule],
declarations: [CourseCompetenciesComponent, CompetencyCardStubComponent, MockPipe(ArtemisTranslatePipe)],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
MockProvider(AlertService),
{ provide: CourseStorageService, useValue: mockCourseStorageService },
MockProvider(CompetencyService),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { LectureUnitService } from 'app/lecture/lecture-unit/lecture-unit-management/lectureUnit.service';
import { MockProvider } from 'ng-mocks';
Expand Down Expand Up @@ -44,8 +44,10 @@ describe('PrerequisiteService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
MockProvider(LectureUnitService, {
convertLectureUnitArrayDatesFromServer<T extends LectureUnit>(res: T[]): T[] {
return res;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpResponse, provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { take } from 'rxjs/operators';
import { ComplaintResponseService } from 'app/complaints/complaint-response.service';
Expand All @@ -23,8 +23,8 @@ describe('ComplaintResponseService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [MockProvider(AccountService)],
imports: [],
providers: [provideHttpClient(), provideHttpClientTesting(), MockProvider(AccountService)],
})
.compileComponents()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { ComplaintResponse } from 'app/entities/complaint-response.model';
import { User } from 'app/core/user/user.model';
import { AccountService } from 'app/core/auth/account.service';
import { MockAccountService } from '../../helpers/mocks/service/mock-account.service';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import dayjs from 'dayjs/esm';
import { Result } from 'app/entities/result.model';
import { Exercise, ExerciseType } from 'app/entities/exercise.model';
import { Course } from 'app/entities/course.model';
import { AssessmentType } from 'app/entities/assessment-type.model';
import { ComplaintRequestDTO } from 'app/entities/complaint-request-dto.model';
import { provideHttpClient } from '@angular/common/http';

describe('ComplaintService', () => {
let complaintService: ComplaintService;
Expand Down Expand Up @@ -57,8 +58,8 @@ describe('ComplaintService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [{ provide: AccountService, useClass: MockAccountService }],
imports: [],
providers: [provideHttpClient(), provideHttpClientTesting(), { provide: AccountService, useClass: MockAccountService }],
})
.compileComponents()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -12,6 +12,7 @@ import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.s
import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service';
import { CourseAdminService } from 'app/course/manage/course-admin.service';
import { UMLDiagramType } from '@ls1intum/apollon';
import { provideHttpClient } from '@angular/common/http';

describe('Course Admin Service', () => {
let courseAdminService: CourseAdminService;
Expand All @@ -23,8 +24,10 @@ describe('Course Admin Service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
{ provide: Router, useClass: MockRouter },
{ provide: LocalStorageService, useClass: MockSyncStorage },
{ provide: SessionStorageService, useClass: MockSyncStorage },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { take } from 'rxjs/operators';
import { AccountService } from 'app/core/auth/account.service';
import { MockAccountService } from '../../helpers/mocks/service/mock-account.service';
import { CourseForImportDTOPagingService } from 'app/course/course-for-import-dto-paging-service';
import { CourseForImportDTO } from 'app/entities/course.model';
import { SortingOrder } from 'app/shared/table/pageable-table';
import { provideHttpClient } from '@angular/common/http';

describe('CourseForImportDtoPagingService', () => {
let pagingService: CourseForImportDTOPagingService;
Expand All @@ -14,8 +15,8 @@ describe('CourseForImportDtoPagingService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [{ provide: AccountService, useClass: MockAccountService }],
imports: [],
providers: [provideHttpClient(), provideHttpClientTesting(), { provide: AccountService, useClass: MockAccountService }],
});

pagingService = TestBed.inject(CourseForImportDTOPagingService);
Expand Down
Loading

0 comments on commit 3779e88

Please sign in to comment.