import { SimpleChange } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; import { DataService } from 'services'; import { HtmlVideoPlayerComponent } from './html-video-player.component'; describe('HtmlVideoPlayerComponent', () => { let component: HtmlVideoPlayerComponent; let fixture: ComponentFixture; // eslint-disable-next-line @typescript-eslint/no-unused-vars let dataService: DataService; const TEST_CHANNEL = { id: '1234', url: 'http://test.ts', name: 'Test channel', group: { title: 'News group', }, http: { 'user-agent': 'localhost', }, }; beforeEach(waitForAsync(() => { const dataServiceMock = { sendIpcEvent: jest.fn().mockResolvedValue(undefined), }; TestBed.configureTestingModule({ imports: [HtmlVideoPlayerComponent, TranslateModule.forRoot()], providers: [{ provide: DataService, useValue: dataServiceMock }], }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(HtmlVideoPlayerComponent); component = fixture.componentInstance; dataService = TestBed.inject(DataService); fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should call play channel function after input changes', () => { jest.spyOn(component, 'playChannel'); jest.spyOn(global.console, 'error').mockImplementation(() => { /* empty */ }); component.ngOnChanges({ channel: new SimpleChange(null, TEST_CHANNEL, true), }); fixture.detectChanges(); expect(component.playChannel).toHaveBeenCalledWith(TEST_CHANNEL); }); });