mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
test: extend tests
This commit is contained in:
2 files changed
+45
-2
No files matched your search
@@ -9,7 +9,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { PlaylistInfoComponent } from './playlist-info.component';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { FormsModule, ReactiveFormsModule, FormBuilder } from '@angular/forms';
|
||||
|
||||
describe('PlaylistInfoComponent', () => {
|
||||
let component: PlaylistInfoComponent;
|
||||
@@ -20,7 +20,7 @@ describe('PlaylistInfoComponent', () => {
|
||||
waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
MockModule(FormsModule),
|
||||
FormsModule,
|
||||
MockModule(MatDialogModule),
|
||||
MockModule(MatFormFieldModule),
|
||||
ReactiveFormsModule,
|
||||
@@ -33,6 +33,7 @@ describe('PlaylistInfoComponent', () => {
|
||||
providers: [
|
||||
{ provide: MAT_DIALOG_DATA, useValue: {} },
|
||||
{ provide: ElectronService, useClass: ElectronServiceStub },
|
||||
FormBuilder,
|
||||
],
|
||||
}).compileComponents();
|
||||
})
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { StorageMap } from '@ngx-pwa/local-storage';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
import { ElectronService } from './../services/electron.service';
|
||||
import { ElectronServiceStub } from './../home/home.component.spec';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
@@ -14,14 +19,25 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { EPG_FETCH } from '../../../ipc-commands';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
class MatSnackBarStub {
|
||||
open(): void {}
|
||||
}
|
||||
|
||||
class MockRouter {
|
||||
navigateByUrl(url: string) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
describe('SettingsComponent', () => {
|
||||
let component: SettingsComponent;
|
||||
let fixture: ComponentFixture<SettingsComponent>;
|
||||
let electronService: ElectronService;
|
||||
let storage: StorageMap;
|
||||
let router: Router;
|
||||
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
@@ -32,11 +48,18 @@ describe('SettingsComponent', () => {
|
||||
MockPipe(TranslatePipe),
|
||||
],
|
||||
providers: [
|
||||
FormBuilder,
|
||||
{ provide: MatSnackBar, useClass: MatSnackBarStub },
|
||||
{
|
||||
provide: TranslateService,
|
||||
useClass: TranslateServiceStub,
|
||||
},
|
||||
{ provide: ElectronService, useClass: ElectronServiceStub },
|
||||
{
|
||||
provide: Router,
|
||||
useClass: MockRouter,
|
||||
},
|
||||
StorageMap,
|
||||
],
|
||||
imports: [
|
||||
HttpClientTestingModule,
|
||||
@@ -56,10 +79,29 @@ describe('SettingsComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SettingsComponent);
|
||||
electronService = TestBed.inject(ElectronService);
|
||||
storage = TestBed.inject(StorageMap);
|
||||
router = TestBed.inject(Router);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create and init component', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should send epg fetch command', () => {
|
||||
spyOn(electronService.ipcRenderer, 'send');
|
||||
component.fetchEpg();
|
||||
expect(electronService.ipcRenderer.send).toHaveBeenCalledWith(
|
||||
EPG_FETCH,
|
||||
{ url: '' }
|
||||
);
|
||||
});
|
||||
|
||||
it('should navigate back to home page', () => {
|
||||
spyOn(router, 'navigateByUrl');
|
||||
component.backToHome();
|
||||
expect(router.navigateByUrl).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user