Skip to content

Commit

Permalink
add dataset component testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesfize committed Mar 11, 2024
1 parent 0248b81 commit 1189887
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DatasetsComponent } from "./datasets.component"
import {
IterableDiffers,
} from '@angular/core';
import { DataFormService } from "../data-form.service";
import { EMPTY, Observable, from } from 'rxjs';
import * as gerard from '../../GN2Common.module';
import { UntypedFormControl } from "@angular/forms";
export class DataFormServiceMock {

constructor() { }
getDatasets(params, queryStrings = {}, fields = []) {
console.log("pouet")
return from([{ dataset_name: "test" }])
}
}

describe("Dataset Component", () => {
it("show component", () => {
cy.mount(DatasetsComponent, {
componentProperties: {
idAcquisitionFramework: 0,
displayOnlyActive: true,
parentFormControl: new UntypedFormControl()
},
imports: [],
declarations: [DatasetsComponent],
providers: [
IterableDiffers,
{ provide: DataFormService, useClass: DataFormServiceMock }
]
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {
} from '@angular/core';
import { DataFormService } from '../data-form.service';
import { GenericFormComponent } from '@geonature_common/form/genericForm.component';
import { CommonService } from '../../service/common.service';
import { ConfigService } from '@geonature/services/config.service';
import { AbstractControl, Validators } from '@angular/forms';
import { Validators } from '@angular/forms';

/**
* Ce composant permet de créer un "input" de type "select" ou "multiselect" affichant l'ensemble des jeux de données sur lesquels l'utilisateur connecté a des droits (table ``gn_meta.t_datasets`` et ``gn_meta.cor_dataset_actor``)
Expand Down Expand Up @@ -60,16 +58,15 @@ export class DatasetsComponent extends GenericFormComponent implements OnInit, O

constructor(
private _dfs: DataFormService,
private _commonService: CommonService,
private _iterableDiffers: IterableDiffers,
public config: ConfigService
) {
super();
this.iterableDiffer = this._iterableDiffers.find([]).create(null);
}

ngOnInit() {
this.bindValue = this.bindAllItem ? null : this.bindValue;
console.log("pouetpouet")
this.getDatasets();
}

Expand Down

0 comments on commit 1189887

Please sign in to comment.