Open NoXeoZ opened 5 months ago
Hi, i'm trying to make the library work on a angular project with test in karma framework
import { Component, Input } from '@angular/core'; import { FiltreLocalStorageService } from 'src/app/service/filter-local-storage/filter-local-storage.service'; import { FiltreDataService } from 'src/app/service/filtre-data/filtre-data.service'; import { SecurityService } from 'src/app/service/security/security.service';
@Component({ selector: 'app-filtre-numero-serie', templateUrl: './filtre-numero-serie.component.html', styleUrls: ['./filtre-numero-serie.component.scss'] }) export class FiltreNumeroSerieComponent {
@Input() vue: string;
numeroSerie: string = '' placeholder: string = "Numéro de série"
constructor(private filtreDataService: FiltreDataService,private storageService :FiltreLocalStorageService,private securityService : SecurityService) { }
onKeyEnter(event: any) { this.filtreDataService.updateFilter(this.vue, { numeroSerie: this.numeroSerie.trim() }); this.securityService.logUserActivityObservable('Vue Borne, utilisation du filtre: matricule valeur ' + this.numeroSerie) }
getNumeroSerie(){ this.filtreDataService.updateFilter(this.vue, { numeroSerie: this.numeroSerie.trim() }); }
ngOnInit(){ let filtresInStorage = this.storageService.getFiltres(this.vue) this.numeroSerie = filtresInStorage ? filtresInStorage.numSerie : '' this.filtreDataService.subscribeToVue(this.vue,(filtreData) => this.numeroSerie = filtreData.numeroSerie) }
}
I got this test generate
// @ts-nocheck import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { Pipe, PipeTransform, Injectable, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, Directive, Input, Output } from '@angular/core'; import { isPlatformBrowser } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { Observable, of as observableOf, throwError } from 'rxjs';
import { Component } from '@angular/core'; import { FiltreNumeroSerieComponent } from './filtre-numero-serie.component'; import { FiltreDataService } from 'src/app/service/filtre-data/filtre-data.service'; import { FiltreLocalStorageService } from 'src/app/service/filter-local-storage/filter-local-storage.service'; import { SecurityService } from 'src/app/service/security/security.service';
@Injectable() class MockFiltreDataService {}
@Injectable() class MockFiltreLocalStorageService {}
@Injectable() class MockSecurityService {}
@Directive({ selector: '[myCustom]' }) class MyCustomDirective { @Input() myCustom; }
.....
Mock are not generated properly, how can i config that ?
Thanks
Hi, i'm trying to make the library work on a angular project with test in karma framework
import { Component, Input } from '@angular/core'; import { FiltreLocalStorageService } from 'src/app/service/filter-local-storage/filter-local-storage.service'; import { FiltreDataService } from 'src/app/service/filtre-data/filtre-data.service'; import { SecurityService } from 'src/app/service/security/security.service';
@Component({ selector: 'app-filtre-numero-serie', templateUrl: './filtre-numero-serie.component.html', styleUrls: ['./filtre-numero-serie.component.scss'] }) export class FiltreNumeroSerieComponent {
@Input() vue: string;
numeroSerie: string = '' placeholder: string = "Numéro de série"
constructor(private filtreDataService: FiltreDataService,private storageService :FiltreLocalStorageService,private securityService : SecurityService) { }
onKeyEnter(event: any) { this.filtreDataService.updateFilter(this.vue, { numeroSerie: this.numeroSerie.trim() }); this.securityService.logUserActivityObservable('Vue Borne, utilisation du filtre: matricule valeur ' + this.numeroSerie) }
getNumeroSerie(){ this.filtreDataService.updateFilter(this.vue, { numeroSerie: this.numeroSerie.trim() }); }
ngOnInit(){ let filtresInStorage = this.storageService.getFiltres(this.vue) this.numeroSerie = filtresInStorage ? filtresInStorage.numSerie : '' this.filtreDataService.subscribeToVue(this.vue,(filtreData) => this.numeroSerie = filtreData.numeroSerie) }
}
I got this test generate
// @ts-nocheck import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { Pipe, PipeTransform, Injectable, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, Directive, Input, Output } from '@angular/core'; import { isPlatformBrowser } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { Observable, of as observableOf, throwError } from 'rxjs';
import { Component } from '@angular/core'; import { FiltreNumeroSerieComponent } from './filtre-numero-serie.component'; import { FiltreDataService } from 'src/app/service/filtre-data/filtre-data.service'; import { FiltreLocalStorageService } from 'src/app/service/filter-local-storage/filter-local-storage.service'; import { SecurityService } from 'src/app/service/security/security.service';
@Injectable() class MockFiltreDataService {}
@Injectable() class MockFiltreLocalStorageService {}
@Injectable() class MockSecurityService {}
@Directive({ selector: '[myCustom]' }) class MyCustomDirective { @Input() myCustom; }
.....
Mock are not generated properly, how can i config that ?
Thanks