Skip to content

Commit

Permalink
[ADF-5279] Date range type filter selection triggers list reload (#6253)
Browse files Browse the repository at this point in the history
* emit event when date is not of range type

* test
  • Loading branch information
pionnegru committed Oct 19, 2020
1 parent ad5fde2 commit eaa9a2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit eaa9a2c

Please sign in to comment.