Skip to content

Commit

Permalink
fix: update deprecated http client and router providers in tests (#275)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Badura <[email protected]>
  • Loading branch information
cbadura and Christian Badura authored Oct 9, 2024
1 parent 989f8c1 commit 9961d40
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
14 changes: 7 additions & 7 deletions src/app/theme/theme-designer/theme-designer.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'
import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing'
import { HttpResponse, HttpErrorResponse } from '@angular/common/http'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { HttpResponse, HttpErrorResponse, provideHttpClient } from '@angular/common/http'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import { By } from '@angular/platform-browser'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
import { RouterTestingModule } from '@angular/router/testing'
import { ActivatedRoute, provideRouter, Router } from '@angular/router'
import { TranslateService } from '@ngx-translate/core'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { of, throwError } from 'rxjs'
Expand All @@ -19,11 +18,11 @@ import { OverlayPanelModule } from 'primeng/overlaypanel'
import { ConfirmDialog, ConfirmDialogModule } from 'primeng/confirmdialog'

import { PortalMessageService, ThemeService } from '@onecx/portal-integration-angular'
import { CurrentThemeTopic } from '@onecx/integration-interface'

import { RefType, ThemesAPIService, ImagesInternalAPIService } from 'src/app/shared/generated'
import { themeVariables } from './theme-variables'
import { ThemeDesignerComponent } from './theme-designer.component'
import { CurrentThemeTopic } from '@onecx/integration-interface'

describe('ThemeDesignerComponent', () => {
let component: ThemeDesignerComponent
Expand Down Expand Up @@ -64,17 +63,18 @@ describe('ThemeDesignerComponent', () => {
DropdownModule,
FormsModule,
InputSwitchModule,
HttpClientTestingModule,
OverlayPanelModule,
ReactiveFormsModule,
RouterTestingModule,
TranslateTestingModule.withTranslations({
de: require('src/assets/i18n/de.json'),
en: require('src/assets/i18n/en.json')
}).withDefaultLanguage('en')
],
schemas: [NO_ERRORS_SCHEMA],
providers: [
provideHttpClientTesting(),
provideHttpClient(),
provideRouter([{ path: '', component: ThemeDesignerComponent }]),
{ provide: PortalMessageService, useValue: msgServiceSpy },
{ provide: ThemeService, useValue: themeServiceSpy },
{ provide: ThemesAPIService, useValue: themeApiSpy },
Expand Down
12 changes: 6 additions & 6 deletions src/app/theme/theme-detail/theme-detail.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'
import { Location } from '@angular/common'
import { HttpErrorResponse } from '@angular/common/http'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { ActivatedRoute, Router } from '@angular/router'
import { RouterTestingModule } from '@angular/router/testing'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import { HttpErrorResponse, provideHttpClient } from '@angular/common/http'
import { ActivatedRoute, provideRouter, Router } from '@angular/router'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { of, throwError } from 'rxjs'
Expand Down Expand Up @@ -43,15 +42,16 @@ describe('ThemeDetailComponent', () => {
TestBed.configureTestingModule({
declarations: [ThemeDetailComponent],
imports: [
RouterTestingModule,
HttpClientTestingModule,
TranslateModule.forRoot(),
TranslateTestingModule.withTranslations({
de: require('src/assets/i18n/de.json'),
en: require('src/assets/i18n/en.json')
}).withDefaultLanguage('de')
],
providers: [
provideHttpClientTesting(),
provideHttpClient(),
provideRouter([{ path: '', component: ThemeDetailComponent }]),
{ provide: UserService, useValue: mockUserService },
{ provide: PortalMessageService, useValue: msgServiceSpy },
{ provide: ConfigurationService, useValue: configServiceSpy },
Expand Down
12 changes: 6 additions & 6 deletions src/app/theme/theme-import/theme-import.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { Router } from '@angular/router'
import { RouterTestingModule } from '@angular/router/testing'
import { HttpResponse, provideHttpClient } from '@angular/common/http'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import { provideRouter, Router } from '@angular/router'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { of, throwError } from 'rxjs'

import { PortalMessageService } from '@onecx/portal-integration-angular'

import { ThemesAPIService } from 'src/app/shared/generated'
import { ThemeImportComponent } from './theme-import.component'
import { HttpResponse } from '@angular/common/http'

describe('ThemeImportComponent', () => {
let component: ThemeImportComponent
Expand All @@ -24,14 +23,15 @@ describe('ThemeImportComponent', () => {
TestBed.configureTestingModule({
declarations: [ThemeImportComponent],
imports: [
RouterTestingModule,
HttpClientTestingModule,
TranslateTestingModule.withTranslations({
de: require('src/assets/i18n/de.json'),
en: require('src/assets/i18n/en.json')
}).withDefaultLanguage('en')
],
providers: [
provideHttpClientTesting(),
provideHttpClient(),
provideRouter([{ path: '', component: ThemeImportComponent }]),
{ provide: PortalMessageService, useValue: msgServiceSpy },
{ provide: ThemesAPIService, useValue: themeApiSpy }
],
Expand Down
15 changes: 9 additions & 6 deletions src/app/theme/theme-search/theme-search.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { NO_ERRORS_SCHEMA } from '@angular/core'
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'
import { Router } from '@angular/router'
import { RouterTestingModule } from '@angular/router/testing'
import { provideHttpClient } from '@angular/common/http'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import { provideRouter, Router } from '@angular/router'
import { TranslateService } from '@ngx-translate/core'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { DataViewModule } from 'primeng/dataview'
Expand All @@ -21,15 +21,18 @@ describe('ThemeSearchComponent', () => {
TestBed.configureTestingModule({
declarations: [ThemeSearchComponent],
imports: [
RouterTestingModule,
HttpClientTestingModule,
DataViewModule,
TranslateTestingModule.withTranslations({
de: require('src/assets/i18n/de.json'),
en: require('src/assets/i18n/en.json')
}).withDefaultLanguage('en')
],
providers: [{ provide: ThemesAPIService, useValue: themeApiSpy }],
providers: [
provideHttpClientTesting(),
provideHttpClient(),
provideRouter([{ path: '', component: ThemeSearchComponent }]),
{ provide: ThemesAPIService, useValue: themeApiSpy }
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents()
}))
Expand Down

0 comments on commit 9961d40

Please sign in to comment.