Untitled
unknown
javascript
4 years ago
6.6 kB
8
Indexable
import { MatDialogMock } from './../../../../../../../../../../testing/dialogs/mockDialogs';
import { TranslateService } from '@ngx-translate/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatDatepickerModule,
MatDialogRef,
MatIconModule,
MatInputModule,
MatListModule,
MatNativeDateModule,
MatPaginatorModule,
MatSelectModule,
MatSidenavModule,
MatSnackBarModule,
MatSortModule,
MatTableModule,
MatToolbarModule,
MatTooltipModule,
MAT_DIALOG_DATA,
} from '@angular/material';
// import { instance, mock, verify, when } from "ts-mockito";
import { NgxSpinnerService } from 'ngx-spinner';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule, FormsModule, FormGroup, FormControl, FormBuilder } from '@angular/forms';
import { ComponentesModule } from 'src/app/componentes/componentes.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ProductosIce } from './../../../../../../../../../../testing/classes/mockClasses';
import { mockAdministracionProductosIce } from './../../../../../../../../../../testing/services/services.mock';
import { AdministracionService } from 'src/app/colaterales/services/administracion.service';
import { CustomValidator } from 'src/app/validation/custom.validation';
import { AddFeeTableComponent } from './add-fee-table.component';
describe('AddFeeTableComponent', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 999999;
let component: AddFeeTableComponent;
let fixture: ComponentFixture<AddFeeTableComponent>, administracionServiceProxy: AdministracionService;
let service = null;
const product: any = ProductosIce;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CommonModule,
ComponentesModule,
CommonModule,
MatTooltipModule,
MatSidenavModule,
MatListModule,
MatIconModule,
MatCardModule,
MatToolbarModule,
MatTableModule,
MatPaginatorModule,
MatInputModule,
MatSelectModule,
MatDatepickerModule,
MatNativeDateModule,
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatSortModule,
MatCheckboxModule,
ReactiveFormsModule,
FormsModule,
HttpClientTestingModule,
MatSnackBarModule,
BrowserAnimationsModule,
],
providers: [
CustomValidator,
TranslateService,
NgxSpinnerService,
FormBuilder,
[
{ provide: MatDialogRef, useClass: MatDialogMock },
{ provide: MAT_DIALOG_DATA, useValue: ProductosIce }
],
{ provide: AdministracionService, useValue: mockAdministracionProductosIce },
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA
],
declarations: [
AddFeeTableComponent
],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddFeeTableComponent);
component = fixture.componentInstance;
administracionServiceProxy = TestBed.get(AdministracionService);
component.dataSource = [{
idProducto: 0,
cierre: 0
},
{
idProducto: 1,
cierre: 1
}
];
let formBuilder: FormBuilder;
formBuilder = TestBed.get(FormBuilder);
const array: FormGroup[] = [];
array.push(new FormGroup({
clearingFee: new FormControl(),
executionFee: new FormControl(),
marketFee: new FormControl(),
}));
array.push(new FormGroup({
clearingFee: new FormControl(),
executionFee: new FormControl(),
marketFee: new FormControl(),
}));
const formArray = formBuilder.array(array);
component.form = new FormGroup({
productFees: formArray // or array not totally sure
});
component.data.producto_edit = {
id: 60,
nombre: 'EUA',
divisa: {
id: 1,
descripcion: 'EUR',
descripcionLarga: null
},
tipoContrato: {
id: 2,
descripcion: 'Derechos de Emisión (U)',
descripcionLarga: null
},
matriz: {
id: 1,
descripcion: 'N/A',
descripcionLarga: null
},
liquidacion: true,
idCotiz: 79,
descClearer: 'ECX CFI FUT',
fechaAlta: 1609455600000,
fechaBaja: 1924988400000,
cuenta: {
id: 2,
descripcion: 'B11U5',
descripcionLarga: 'EURIBGESP'
},
contraparte: {
id: 1,
descripcion: 'ECX',
descripcionLarga: null
},
fees: [
{
id: null,
idProducto: 60,
cierre: false,
marketFee: 0.0004,
executionFee: 0,
clearingFee: 0.0001
},
{
id: null,
idProducto: 60,
cierre: true,
marketFee: 0,
executionFee: 0,
clearingFee: 0.0010055
}
]
};
fixture.detectChanges();
component.subscribeArrays = [];
service = fixture.debugElement.injector.get(AdministracionService);
});
it('should call onInit', () => {
component.ngOnInit();
});
it('should call onNoClick', () => {
component.onNoClick();
});
});
Editor is loading...