Some methods angular material, i need to unit test of each one, but i don't know how
/**
* Setup the filter for a table
* @param dataTable data source to setup
*/
private setupFilter(dataTable: MatTableDataSource<Element>) {
dataTable.filterPredicate = (data: any, filter: string) => {
filter = filter.toLowerCase();
return data.name.toLowerCase().includes(filter)
|| data.description.toString().includes(filter);
};
}
Some methods angular material, i need to unit test of each one, but i don't know how
/**
* Checking control validation for edit inputs
* @param value Equals to ngmodel for the input
* @param column Equals to column name
*/
public editControlHasError(value: string, column: string): void {
if (column === 'name') {
this.errorInName.required = value === '';
this.errorInName.maxlength = value.length > Constants.MAX_LENGTH_NAME;
return;
}
this.errorInDescription.required = value === '';
this.errorInDescription.maxlength = value.length > Constants.MAX_LENGTH_DESCRIPTION;
}
Some methods angular material, i need to unit test of each one, but i don't know how
/**
* Methode that apply the table filter
* @param filterValue the filter value
*/
public applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
Some methods angular material, i need to unit test of each one, but i don't know how /** * Clear the filters value */ clearFilters() { this.filter = ''; this.dataSource.filter = ''; }
Some methods angular material, i need to unit test of each one, but i don't know how
/**
* Method that loads a list of profiles to display on the rol select
*/
private loadProfiles() {
this.loaders.dataSource = true;
this.profilesService.getAllProfiles()
.pipe(
finalize(() => {
this.loaders.dataSource = false;
this.updateDOM();
})
)
.subscribe(
data => {
this.dataSource = new MatTableDataSource<Element>(data);
// getting properties from the object to sort the column from nested objects
this.dataSource.sortingDataAccessor = (obj, property) =>
this.getProperty(obj, property);
this.dataSource.sort = this.sort;
this.setupFilter(this.dataSource);
}
);
}
Some methods angular material, i need to unit test of each one, but i don't know how
/**
* Method that create a Profile
*/
public addProfile() {
for (const key in this.profileForm.controls) {
if (this.profileForm.controls[key] &&
this.profileForm.controls[key].value.toString().trim() === '') {
this.profileForm.controls[key].setValue('');
}
}
if (this.profileForm.valid) {
this.loaders.process = true;
const profile: Profile = new Profile();
profile.idProfile = 0;
profile.name = this.profileForm.controls.name.value.trim();
profile.description = this.profileForm.controls.description.value.trim();
this.profilesService.addProfile(profile).subscribe(
data => {
this.loaders.process = false;
this.profileForm.reset();
this.loadProfiles();
this.showModalAlert(data);
}
);
}
}
Some methods angular material, i need to unit test of each one, but i don't know how
/**
* Method that loads a profile for edit from the list
*/
public loadEditProfile(element: Profile) {
if (this.dataSource.data.some((e: any) => !!e.edit)) {
this.cancelEdit();
this.initErrorCheckers();
}
this.profileElementTmp = JSON.parse(JSON.stringify(element));
this.profileElementAux = element;
element.edit = true;
}
Some methods angular material, i need to unit test of each one, but i don't know how