Enhance unit tests for ClientTaskLogs and OutputDialog components by adding necessary imports, providers, and schemas
testing/ogGui-multibranch/pipeline/head This commit looks good Details

pull/22/head
Lucas Lara García 2025-05-09 13:07:19 +02:00
parent 757de78dc4
commit d10a209a25
2 changed files with 49 additions and 9 deletions

View File

@ -1,16 +1,48 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ClientTaskLogsComponent } from './client-task-logs.component';
import { JoyrideService } from 'ngx-joyride';
import { ToastrModule } from 'ngx-toastr';
import { ConfigService } from '@services/config.service';
import { MatIconModule } from '@angular/material/icon';
import { TranslateModule } from '@ngx-translate/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { LoadingComponent } from 'src/app/shared/loading/loading.component';
import { MatPaginatorModule } from '@angular/material/paginator';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
describe('ClientTaskLogsComponent', () => {
let component: ClientTaskLogsComponent;
let fixture: ComponentFixture<ClientTaskLogsComponent>;
beforeEach(async () => {
const mockJoyrideService = jasmine.createSpyObj('JoyrideService', ['startTour']);
const mockConfigService = {
apiUrl: 'http://mock-api-url'
};
await TestBed.configureTestingModule({
declarations: [ClientTaskLogsComponent]
})
.compileComponents();
declarations: [ClientTaskLogsComponent, LoadingComponent],
imports: [HttpClientTestingModule,
ToastrModule.forRoot(),
MatIconModule,
TranslateModule.forRoot(),
MatFormFieldModule,
MatPaginatorModule,
MatSelectModule,
BrowserAnimationsModule
],
providers: [
{ provide: MatDialogRef, useValue: { close: jasmine.createSpy('close') } },
{ provide: MAT_DIALOG_DATA, useValue: {} },
{ provide: JoyrideService, useValue: mockJoyrideService },
{ provide: ConfigService, useValue: mockConfigService }
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
fixture = TestBed.createComponent(ClientTaskLogsComponent);
component = fixture.componentInstance;
@ -20,4 +52,4 @@ describe('ClientTaskLogsComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
});
});

View File

@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { OutputDialogComponent } from './output-dialog.component';
import { TranslateModule } from '@ngx-translate/core';
describe('OutputDialogComponent', () => {
let component: OutputDialogComponent;
@ -8,9 +9,16 @@ describe('OutputDialogComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [OutputDialogComponent]
declarations: [OutputDialogComponent],
imports: [
TranslateModule.forRoot()
],
providers: [
{ provide: MatDialogRef, useValue: { close: jasmine.createSpy('close') } },
{ provide: MAT_DIALOG_DATA, useValue: { input: {} } }
]
})
.compileComponents();
.compileComponents();
fixture = TestBed.createComponent(OutputDialogComponent);
component = fixture.componentInstance;
@ -20,4 +28,4 @@ describe('OutputDialogComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
});
});