mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
test: fix issues in basic unit tests
This commit is contained in:
1 parent
f4cbd6ceed
commit
9323223803
3 files changed
+98
-41
No files matched your search
@@ -2,20 +2,34 @@ import { TestBed, async } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ElectronService } from './core/services';
|
||||
import { ElectronService } from './services/electron.service';
|
||||
import { ElectronServiceStub } from './home/home.component.spec';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
providers: [ElectronService],
|
||||
imports: [RouterTestingModule, TranslateModule.forRoot()]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('should create the app', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
jest.mock('custom-electron-titlebar', () => {
|
||||
return {
|
||||
Titlebar: jest.fn().mockImplementation(() => {
|
||||
return {};
|
||||
}),
|
||||
Color: {
|
||||
fromHex: jest.fn(),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('AppComponen t', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
providers: [
|
||||
{ provide: ElectronService, useClass: ElectronServiceStub },
|
||||
],
|
||||
imports: [RouterTestingModule, TranslateModule.forRoot()],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('should create the app', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -1,28 +1,27 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { FileUploadComponent } from './file-upload.component';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MockModule } from 'ng-mocks';
|
||||
import { NgxUploaderModule } from 'ngx-uploader';
|
||||
|
||||
describe('FileUploadComponent', () => {
|
||||
let component: FileUploadComponent;
|
||||
let fixture: ComponentFixture<FileUploadComponent>;
|
||||
let component: FileUploadComponent;
|
||||
let fixture: ComponentFixture<FileUploadComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ FileUploadComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [FileUploadComponent],
|
||||
imports: [MockModule(MatIconModule), NgxUploaderModule],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FileUploadComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FileUploadComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,21 +1,65 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MockComponent, MockModule } from 'ng-mocks';
|
||||
import { HomeComponent } from './home.component';
|
||||
import { HeaderComponent } from '../shared/components/header/header.component';
|
||||
import { RecentPlaylistsComponent } from '../home/recent-playlists/recent-playlists.component';
|
||||
import { FileUploadComponent } from '../home/file-upload/file-upload.component';
|
||||
import { UrlUploadComponent } from '../home/url-upload/url-upload.component';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { ElectronService } from '../services/electron.service';
|
||||
|
||||
class MatSnackBarStub {
|
||||
open(): void {}
|
||||
}
|
||||
|
||||
export class ElectronServiceStub {
|
||||
ipcRenderer = {
|
||||
send: jest.fn(),
|
||||
on: jest.fn(),
|
||||
};
|
||||
remote = {
|
||||
process: {
|
||||
platform: 'linux',
|
||||
argv: [0, 1],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [HomeComponent],
|
||||
declarations: [
|
||||
HomeComponent,
|
||||
MockComponent(HeaderComponent),
|
||||
MockComponent(FileUploadComponent),
|
||||
MockComponent(RecentPlaylistsComponent),
|
||||
MockComponent(UrlUploadComponent),
|
||||
],
|
||||
imports: [
|
||||
MockModule(MatTabsModule),
|
||||
MockModule(MatIconModule),
|
||||
MockModule(MatProgressBarModule),
|
||||
MockModule(MatSnackBarModule),
|
||||
RouterTestingModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: MatSnackBar, useClass: MatSnackBarStub },
|
||||
{ provide: ElectronService, useClass: ElectronServiceStub },
|
||||
],
|
||||
}).compileComponents();
|
||||
}));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
TestBed.inject(ElectronService);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user