mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-5279] Date range type filter selection triggers list reload (#6253)
* emit event when date is not of range type * test
This commit is contained in:
parent
ad5fde2058
commit
eaa9a2c1f7
@ -20,7 +20,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed } from 'core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import { DateCloudFilterType } from '../../models/date-cloud-filter.model';
|
||||
import { DateRangeFilterService } from './date-range-filter.service';
|
||||
@ -64,14 +63,26 @@ describe('DateRangeFilterComponent', () => {
|
||||
stateElement.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
const options = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
options[2].nativeElement.click();
|
||||
const weekOption = document.querySelector('[data-automation-id="adf-cloud-edit-process-property-options-WEEK"]') as HTMLElement;
|
||||
weekOption.click();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(service.getDateRange).not.toHaveBeenCalled();
|
||||
expect(component.dateTypeChange.emit).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not emit event on `RANGE` option change', async () => {
|
||||
spyOn(component.dateTypeChange, 'emit');
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-createdDate"] .mat-select-trigger');
|
||||
stateElement.click();
|
||||
fixture.detectChanges();
|
||||
const rangeOption = document.querySelector('[data-automation-id="adf-cloud-edit-process-property-options-RANGE"]') as HTMLElement;
|
||||
rangeOption.click();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(component.dateTypeChange.emit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reset date range when no_date type is selected', () => {
|
||||
const expectedDate = {
|
||||
startDate: null,
|
||||
|
@ -59,7 +59,9 @@ import moment from 'moment-es6';
|
||||
|
||||
onSelectionChange(option: MatSelectChange) {
|
||||
this.type = option.value;
|
||||
this.dateTypeChange.emit(this.type);
|
||||
if (!this.isDateRangeType()) {
|
||||
this.dateTypeChange.emit(this.type);
|
||||
}
|
||||
}
|
||||
|
||||
isDateRangeType(): boolean {
|
||||
|
Loading…
x
Reference in New Issue
Block a user