From 6768efe4de6ccf5c28f95ce56fe548f7b1fd2701 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sat, 16 Mar 2024 12:36:39 +0100 Subject: [PATCH] fix(epg): improve error handling --- src/app/app.component.spec.ts | 56 +++++++++++++++++------------------ src/app/app.component.ts | 5 +++- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 7034746a9..d2453c1b4 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -36,34 +36,32 @@ describe('AppComponent', () => { let whatsNewService: WhatsNewService; const defaultLanguage = 'en'; - beforeEach( - waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [AppComponent, MockPipe(TranslatePipe)], - providers: [ - { provide: WhatsNewService, useClass: WhatsNewServiceStub }, - MockProviders( - TranslateService, - PlaylistsService, - NgxIndexedDBService, - MatSnackBar - ), - SettingsService, - { - provide: DataService, - useClass: ElectronServiceStub, - }, - provideMockStore(), - ], - imports: [ - MockModule(MatSnackBarModule), - MockModule(NgxWhatsNewModule), - RouterTestingModule, - HttpClientTestingModule, - ], - }).compileComponents(); - }) - ); + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [AppComponent, MockPipe(TranslatePipe)], + providers: [ + { provide: WhatsNewService, useClass: WhatsNewServiceStub }, + MockProviders( + TranslateService, + PlaylistsService, + NgxIndexedDBService, + MatSnackBar + ), + SettingsService, + { + provide: DataService, + useClass: ElectronServiceStub, + }, + provideMockStore(), + ], + imports: [ + MockModule(MatSnackBarModule), + MockModule(NgxWhatsNewModule), + RouterTestingModule, + HttpClientTestingModule, + ], + }).compileComponents(); + })); beforeEach(() => { electronService = TestBed.inject(DataService); @@ -203,7 +201,7 @@ describe('AppComponent', () => { describe('Set initial settings', () => { const theme = Theme.DarkTheme; const language = 'es'; - const epgUrl = 'http://localhost/epg.xml'; + const epgUrl = ['http://localhost/epg.xml']; beforeEach(() => { jest.spyOn(electronService, 'sendIpcEvent'); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index cb66d247e..622d6b4d2 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -149,7 +149,10 @@ export class AppComponent { .subscribe((settings: Settings) => { if (settings && Object.keys(settings).length > 0) { this.translate.use(settings.language ?? this.DEFAULT_LANG); - if (settings.epgUrl) { + if ( + settings.epgUrl?.length > 0 && + settings.epgUrl?.some((u) => u !== '') + ) { this.epgService.fetchEpg(settings.epgUrl); }