test: enhance ChangeParentComponent tests with necessary imports and providers

pull/24/head^2
Lucas Lara García 2025-05-30 09:31:56 +02:00
parent 4e23723717
commit 8882fd40a5
1 changed files with 26 additions and 3 deletions

View File

@ -1,16 +1,39 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeParentComponent } from './change-parent.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { ToastrService } from 'ngx-toastr';
import { ConfigService } from '@services/config.service';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
describe('ChangeParentComponent', () => {
let component: ChangeParentComponent;
let fixture: ComponentFixture<ChangeParentComponent>;
beforeEach(async () => {
const mockConfigService = { apiUrl: 'http://mock-api-url' };
await TestBed.configureTestingModule({
declarations: [ChangeParentComponent]
declarations: [ChangeParentComponent],
imports: [
HttpClientTestingModule,
MatDialogModule,
MatFormFieldModule,
MatSelectModule,
FormsModule,
BrowserAnimationsModule
],
providers: [
{ provide: MatDialogRef, useValue: {} },
{ provide: MAT_DIALOG_DATA, useValue: { clients: [] } },
{ provide: ToastrService, useValue: { success: () => { }, error: () => { } } },
{ provide: ConfigService, useValue: mockConfigService }
]
})
.compileComponents();
.compileComponents();
fixture = TestBed.createComponent(ChangeParentComponent);
component = fixture.componentInstance;