test: add missing dependency

This commit is contained in:
4gray committed 2021-02-19 19:32:53 +01:00
1 parent b79cf37476
commit c03da33c44
7 files changed
+62 -34

No files matched your search

+26 -21
View File
@@ -1,11 +1,11 @@
import { TestBed, waitForAsync } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { TranslateModule } from '@ngx-translate/core';
import { TranslateModule, TranslatePipe } from '@ngx-translate/core';
import { ElectronService } from './services/electron.service';
import { ElectronServiceStub } from './home/home.component.spec';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { MockModule } from 'ng-mocks';
import { MockModule, MockPipe } from 'ng-mocks';
jest.mock('custom-electron-titlebar', () => {
return {
@@ -23,24 +23,29 @@ class MatSnackBarStub {
}
describe('AppComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
providers: [
{ provide: ElectronService, useClass: ElectronServiceStub },
{ provide: MatSnackBar, useClass: MatSnackBarStub },
],
imports: [
MockModule(MatSnackBarModule),
RouterTestingModule,
TranslateModule.forRoot(),
],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent, MockPipe(TranslatePipe)],
providers: [
{ provide: ElectronService, useClass: ElectronServiceStub },
{ provide: MatSnackBar, useClass: MatSnackBarStub },
],
imports: [
MockModule(MatSnackBarModule),
RouterTestingModule,
TranslateModule.forRoot(),
],
}).compileComponents();
})
);
it('should create the app', waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(
'should create the app',
waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
})
);
});
@@ -1,19 +1,29 @@
import { TranslateService, TranslatePipe } from '@ngx-translate/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FileUploadComponent } from './file-upload.component';
import { MatIconModule } from '@angular/material/icon';
import { MockModule } from 'ng-mocks';
import { MockModule, MockPipe } from 'ng-mocks';
import { NgxUploaderModule } from 'ngx-uploader';
import { TranslateServiceStub } from '../../../testing/translate.stub';
describe('FileUploadComponent', () => {
let component: FileUploadComponent;
let fixture: ComponentFixture<FileUploadComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [FileUploadComponent],
imports: [MockModule(MatIconModule), NgxUploaderModule],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [FileUploadComponent, MockPipe(TranslatePipe)],
imports: [MockModule(MatIconModule), NgxUploaderModule],
providers: [
{
provide: TranslateService,
useClass: TranslateServiceStub,
},
],
}).compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(FileUploadComponent);
+3 -1
View File
@@ -1,5 +1,6 @@
import { TranslatePipe } from '@ngx-translate/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MockComponent, MockModule } from 'ng-mocks';
import { MockComponent, MockModule, MockPipe } 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';
@@ -42,6 +43,7 @@ describe('HomeComponent', () => {
MockComponent(FileUploadComponent),
MockComponent(RecentPlaylistsComponent),
MockComponent(UrlUploadComponent),
MockPipe(TranslatePipe),
],
imports: [
MockModule(MatTabsModule),
@@ -1,4 +1,5 @@
import { MockModule } from 'ng-mocks';
import { TranslatePipe } from '@ngx-translate/core';
import { MockModule, MockPipe } from 'ng-mocks';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
@@ -16,7 +17,7 @@ describe('PlaylistInfoComponent', () => {
MockModule(MatDialogModule),
MockModule(MatFormFieldModule),
],
declarations: [PlaylistInfoComponent],
declarations: [PlaylistInfoComponent, MockPipe(TranslatePipe)],
providers: [{ provide: MAT_DIALOG_DATA, useValue: {} }],
}).compileComponents();
})
@@ -1,3 +1,5 @@
import { TranslatePipe } from '@ngx-translate/core';
import { MockPipe } from 'ng-mocks';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
@@ -13,7 +15,7 @@ describe('UrlUploadComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [UrlUploadComponent],
declarations: [UrlUploadComponent, MockPipe(TranslatePipe)],
imports: [
MatInputModule,
FormsModule,
@@ -1,3 +1,4 @@
import { TranslatePipe } from '@ngx-translate/core';
/* eslint-disable @typescript-eslint/unbound-method */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChannelListContainerComponent } from './channel-list-container.component';
@@ -9,7 +10,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
import { MatTabsModule } from '@angular/material/tabs';
import { MatExpansionModule } from '@angular/material/expansion';
import { MockModule } from 'ng-mocks';
import { MockModule, MockPipe } from 'ng-mocks';
import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { FilterPipeModule } from 'ngx-filter-pipe';
@@ -31,7 +32,10 @@ describe('ChannelListContainerComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ChannelListContainerComponent],
declarations: [
ChannelListContainerComponent,
MockPipe(TranslatePipe),
],
providers: [
ChannelQuery,
{ provide: MatSnackBar, useClass: MatSnackBarStub },
+4
View File
@@ -0,0 +1,4 @@
/** Translate Service Stub */
export class TranslateServiceStub {
instant(): void {}
}