From 7e28686df3344158669de7df4d648f51ccc5f9cd Mon Sep 17 00:00:00 2001 From: 4gray Date: Tue, 19 Nov 2024 00:02:40 +0100 Subject: [PATCH] test: resolve import issues in spec files --- src/app/app.module.ts | 1 - .../epg-list-item.component.spec.ts | 31 ++++---- .../video-player.component.spec.ts | 78 +++++++++---------- src/app/services/electron.service.stub.ts | 4 + src/app/settings/settings.component.spec.ts | 4 +- src/app/shared/pipes/moment-date.pipe.spec.ts | 2 +- 6 files changed, 58 insertions(+), 62 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index bc44dd641..f116a2905 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -7,7 +7,6 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ServiceWorkerModule } from '@angular/service-worker'; -// NG Translate import { EffectsModule } from '@ngrx/effects'; import { StoreRouterConnectingModule, routerReducer } from '@ngrx/router-store'; import { StoreModule } from '@ngrx/store'; diff --git a/src/app/player/components/epg-list/epg-list-item/epg-list-item.component.spec.ts b/src/app/player/components/epg-list/epg-list-item/epg-list-item.component.spec.ts index 12e83a841..6c6c76065 100644 --- a/src/app/player/components/epg-list/epg-list-item/epg-list-item.component.spec.ts +++ b/src/app/player/components/epg-list/epg-list-item/epg-list-item.component.spec.ts @@ -4,7 +4,7 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { MatIconModule } from '@angular/material/icon'; import { MatListModule } from '@angular/material/list'; import { MatTooltipModule } from '@angular/material/tooltip'; -import { TranslatePipe } from '@ngx-translate/core'; +import { TranslateModule } from '@ngx-translate/core'; import * as moment from 'moment'; import { MockModule, MockPipe } from 'ng-mocks'; import { MomentDatePipe } from './../../../../shared/pipes/moment-date.pipe'; @@ -61,23 +61,18 @@ describe('EpgListItemComponent', () => { let fixture: ComponentFixture; let dialog: MatDialog; - beforeEach( - waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ - EpgListItemComponent, - MockPipe(MomentDatePipe), - MockPipe(TranslatePipe), - ], - imports: [ - MockModule(MatDialogModule), - MockModule(MatListModule), - MockModule(MatIconModule), - MockModule(MatTooltipModule), - ], - }).compileComponents(); - }) - ); + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [EpgListItemComponent, MockPipe(MomentDatePipe)], + imports: [ + MockModule(MatDialogModule), + MockModule(MatListModule), + MockModule(MatIconModule), + MockModule(MatTooltipModule), + MockModule(TranslateModule), + ], + }).compileComponents(); + })); beforeEach(() => { fixture = TestBed.createComponent(EpgListItemComponent); diff --git a/src/app/player/components/video-player/video-player.component.spec.ts b/src/app/player/components/video-player/video-player.component.spec.ts index 627d41960..67dfbeeb7 100644 --- a/src/app/player/components/video-player/video-player.component.spec.ts +++ b/src/app/player/components/video-player/video-player.component.spec.ts @@ -20,6 +20,7 @@ import { VjsPlayerComponent } from '../vjs-player/vjs-player.component'; import { InfoOverlayComponent } from './../info-overlay/info-overlay.component'; import { VideoPlayerComponent } from './video-player.component'; +import { CommonModule } from '@angular/common'; import { Actions } from '@ngrx/effects'; import { provideMockActions } from '@ngrx/effects/testing'; import { NgxIndexedDBService } from 'ngx-indexed-db'; @@ -37,48 +38,47 @@ describe('VideoPlayerComponent', () => { let mockStore: MockStore; const actions$ = new Observable(); - beforeEach( - waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ - MockComponent(EpgListComponent), - MockComponent(HtmlVideoPlayerComponent), - MockComponent(VjsPlayerComponent), - MockComponent(VideoPlayerComponent), - MockComponent(ChannelListContainerComponent), - MockComponent(InfoOverlayComponent), - VideoPlayerComponent, - MockPipe(TranslatePipe), - ], - providers: [ - { provide: MatSnackBar, useClass: MatSnackBarStub }, - { provide: DataService, useClass: ElectronServiceStub }, - { - provide: ActivatedRoute, - useValue: { - params: of({ id: '1' }), - snapshot: { - queryParams: { - url: 'https://iptvnator/list.m3u', - }, + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ + MockComponent(EpgListComponent), + MockComponent(HtmlVideoPlayerComponent), + MockComponent(VjsPlayerComponent), + MockComponent(VideoPlayerComponent), + MockComponent(ChannelListContainerComponent), + MockComponent(InfoOverlayComponent), + VideoPlayerComponent, + MockPipe(TranslatePipe), + CommonModule, + ], + providers: [ + { provide: MatSnackBar, useClass: MatSnackBarStub }, + { provide: DataService, useClass: ElectronServiceStub }, + { + provide: ActivatedRoute, + useValue: { + params: of({ id: '1' }), + snapshot: { + queryParams: { + url: 'https://iptvnator/list.m3u', }, }, }, - provideMockStore(), - provideMockActions(actions$), - MockProviders(NgxIndexedDBService, PlaylistsService), - ], - imports: [ - MockModule(MatSidenavModule), - MockModule(MatIconModule), - MockModule(MatToolbarModule), - MockModule(MatTooltipModule), - MockModule(RouterTestingModule), - MockModule(MatDividerModule), - ], - }).compileComponents(); - }) - ); + }, + provideMockStore(), + provideMockActions(actions$), + MockProviders(NgxIndexedDBService, PlaylistsService), + ], + imports: [ + MockModule(MatSidenavModule), + MockModule(MatIconModule), + MockModule(MatToolbarModule), + MockModule(MatTooltipModule), + MockModule(RouterTestingModule), + MockModule(MatDividerModule), + ], + }).compileComponents(); + })); beforeEach(() => { fixture = TestBed.createComponent(VideoPlayerComponent); diff --git a/src/app/services/electron.service.stub.ts b/src/app/services/electron.service.stub.ts index 785a781ae..eee603144 100644 --- a/src/app/services/electron.service.stub.ts +++ b/src/app/services/electron.service.stub.ts @@ -25,4 +25,8 @@ export class ElectronServiceStub { sendIpcEvent() {} listenOn() {} + + getAppEnvironment() { + return 'electron'; + } } diff --git a/src/app/settings/settings.component.spec.ts b/src/app/settings/settings.component.spec.ts index 352783853..4f3356762 100644 --- a/src/app/settings/settings.component.spec.ts +++ b/src/app/settings/settings.component.spec.ts @@ -35,7 +35,6 @@ import { EPG_FORCE_FETCH } from '../../../shared/ipc-commands'; import { DataService } from '../services/data.service'; import { ElectronServiceStub } from '../services/electron.service.stub'; import { HeaderComponent } from '../shared/components'; -import { SharedModule } from '../shared/shared.module'; import { Language } from './language.enum'; import { SettingsComponent } from './settings.component'; import { VideoPlayer } from './settings.interface'; @@ -63,7 +62,7 @@ const DEFAULT_SETTINGS = { mpvPlayerPath: '', vlcPlayerPath: '', remoteControl: false, - remoteControlPort: 3000 + remoteControlPort: 3000, }; describe('SettingsComponent', () => { @@ -108,7 +107,6 @@ describe('SettingsComponent', () => { MockModule(MatCheckboxModule), MockModule(MatDividerModule), MockModule(TranslateModule), - MockModule(SharedModule), ], }).compileComponents(); })); diff --git a/src/app/shared/pipes/moment-date.pipe.spec.ts b/src/app/shared/pipes/moment-date.pipe.spec.ts index a040350e4..82ff81d30 100644 --- a/src/app/shared/pipes/moment-date.pipe.spec.ts +++ b/src/app/shared/pipes/moment-date.pipe.spec.ts @@ -1,6 +1,6 @@ import { MomentDatePipe } from './moment-date.pipe'; -describe('Pipe: MomentDatee', () => { +describe('Pipe: MomentDate', () => { it('create an instance', () => { const pipe = new MomentDatePipe(); expect(pipe).toBeTruthy();