Enhance unit tests for ConvertImageToVirtualComponent with improved mock services and dependencies
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
parent
09d3420387
commit
081f9a9846
|
@ -1,16 +1,45 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { provideHttpClient } from '@angular/common/http';
|
||||||
|
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||||
import { ConvertImageToVirtualComponent } from './convert-image-to-virtual.component';
|
import { ConvertImageToVirtualComponent } from './convert-image-to-virtual.component';
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import { ToastrModule } from 'ngx-toastr';
|
||||||
|
import { ConfigService } from '@services/config.service';
|
||||||
|
|
||||||
describe('ConvertImageToVirtualComponent', () => {
|
describe('ConvertImageToVirtualComponent', () => {
|
||||||
let component: ConvertImageToVirtualComponent;
|
let component: ConvertImageToVirtualComponent;
|
||||||
let fixture: ComponentFixture<ConvertImageToVirtualComponent>;
|
let fixture: ComponentFixture<ConvertImageToVirtualComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const mockConfigService = {
|
||||||
|
apiUrl: 'http://mock-api-url'
|
||||||
|
};
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ConvertImageToVirtualComponent]
|
declarations: [ConvertImageToVirtualComponent],
|
||||||
|
imports: [
|
||||||
|
MatDialogModule,
|
||||||
|
ToastrModule.forRoot()
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
provideHttpClient(),
|
||||||
|
provideHttpClientTesting(),
|
||||||
|
{
|
||||||
|
provide: MatDialogRef,
|
||||||
|
useValue: {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: MAT_DIALOG_DATA,
|
||||||
|
useValue: {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: ConfigService,
|
||||||
|
useValue: mockConfigService
|
||||||
|
}
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ConvertImageToVirtualComponent);
|
fixture = TestBed.createComponent(ConvertImageToVirtualComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
@ -20,4 +49,4 @@ describe('ConvertImageToVirtualComponent', () => {
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue