mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
fix random test failing part 2 (#3395)
* fix random failing test core search/comment/auth/user * fix node delete directive * fix lint issues * node restore fix * fix comment test * remove fdescribe * fix tests and tslint * fix upload test * unsubscribe success event task test * copy comment object during test * use the data pipe performance improvement and standard usage * uncomment random test * fix comment date random failing test * disposable unsubscribe * fix start process * remove fdescribe * change start process test and remove commented code * fix error event check double click * clone object form test * refactor date time test * fix service mock * fix test dropdown and context * git hook lint * fix language test * unsubscribe documentlist event test * fix disposable error * fix console log service error document list * unusbscribe search test * clear input field * remove wrong test
This commit is contained in:
committed by
Denys Vuika
parent
22006395c7
commit
eb0f91c5db
@@ -42,7 +42,7 @@ describe('SearchDateRangeComponent', () => {
|
||||
|
||||
const buildUserPreferences = (): any => {
|
||||
const userPreferences = {
|
||||
userPreferenceStatus: {LOCALE: localeFixture},
|
||||
userPreferenceStatus: { LOCALE: localeFixture },
|
||||
select: (property) => {
|
||||
return Observable.of(userPreferences.userPreferenceStatus[property]);
|
||||
}
|
||||
@@ -63,45 +63,39 @@ describe('SearchDateRangeComponent', () => {
|
||||
expect(component.form).toBeDefined();
|
||||
});
|
||||
|
||||
it('should setup locale from userPreferencesService', () => {
|
||||
spyOn(component, 'setLocale').and.stub();
|
||||
component.ngOnInit();
|
||||
expect(component.setLocale).toHaveBeenCalledWith(localeFixture);
|
||||
});
|
||||
|
||||
it('should setup the format of the date from configuration', () => {
|
||||
component.settings = {field: 'cm:created', dateFormat: dateFormatFixture};
|
||||
component.settings = { field: 'cm:created', dateFormat: dateFormatFixture };
|
||||
component.ngOnInit();
|
||||
expect(theDateAdapter.overrideDisplyaFormat).toBe(dateFormatFixture);
|
||||
});
|
||||
|
||||
it('should setup form control with formatted valid date on change', () => {
|
||||
component.settings = {field: 'cm:created', dateFormat: dateFormatFixture};
|
||||
component.settings = { field: 'cm:created', dateFormat: dateFormatFixture };
|
||||
component.ngOnInit();
|
||||
|
||||
const inputString = '20-feb-18';
|
||||
const momentFromInput = moment(inputString, dateFormatFixture);
|
||||
expect(momentFromInput.isValid()).toBeTruthy();
|
||||
|
||||
component.onChangedHandler({srcElement: {value: inputString}}, component.from);
|
||||
component.onChangedHandler({ srcElement: { value: inputString } }, component.from);
|
||||
expect(component.from.value.toString()).toEqual(momentFromInput.toString());
|
||||
});
|
||||
|
||||
it('should NOT setup form control with invalid date on change', () => {
|
||||
component.settings = {field: 'cm:created', dateFormat: dateFormatFixture};
|
||||
component.settings = { field: 'cm:created', dateFormat: dateFormatFixture };
|
||||
component.ngOnInit();
|
||||
|
||||
const inputString = '20.f.18';
|
||||
const momentFromInput = moment(inputString, dateFormatFixture);
|
||||
expect(momentFromInput.isValid()).toBeFalsy();
|
||||
|
||||
component.onChangedHandler({srcElement: {value: inputString}}, component.from);
|
||||
component.onChangedHandler({ srcElement: { value: inputString } }, component.from);
|
||||
expect(component.from.value.toString()).not.toEqual(momentFromInput.toString());
|
||||
});
|
||||
|
||||
it('should reset form', () => {
|
||||
component.ngOnInit();
|
||||
component.form.setValue({from: fromDate, to: toDate});
|
||||
component.form.setValue({ from: fromDate, to: toDate });
|
||||
|
||||
expect(component.from.value).toEqual(fromDate);
|
||||
expect(component.to.value).toEqual(toDate);
|
||||
@@ -110,7 +104,7 @@ describe('SearchDateRangeComponent', () => {
|
||||
|
||||
expect(component.from.value).toEqual('');
|
||||
expect(component.to.value).toEqual('');
|
||||
expect(component.form.value).toEqual({from: '', to: ''});
|
||||
expect(component.form.value).toEqual({ from: '', to: '' });
|
||||
});
|
||||
|
||||
it('should update query builder on reset', () => {
|
||||
@@ -118,7 +112,8 @@ describe('SearchDateRangeComponent', () => {
|
||||
queryFragments: {
|
||||
createdDateRange: 'query'
|
||||
},
|
||||
update() {}
|
||||
update() {
|
||||
}
|
||||
};
|
||||
|
||||
component.id = 'createdDateRange';
|
||||
@@ -136,12 +131,13 @@ describe('SearchDateRangeComponent', () => {
|
||||
it('should update query builder on value changes', () => {
|
||||
const context: any = {
|
||||
queryFragments: {},
|
||||
update() {}
|
||||
update() {
|
||||
}
|
||||
};
|
||||
|
||||
component.id = 'createdDateRange';
|
||||
component.context = context;
|
||||
component.settings = {field: 'cm:created'};
|
||||
component.settings = { field: 'cm:created' };
|
||||
|
||||
spyOn(context, 'update').and.stub();
|
||||
|
||||
@@ -180,10 +176,14 @@ describe('SearchDateRangeComponent', () => {
|
||||
return Observable.of(key);
|
||||
});
|
||||
|
||||
component.settings = {'dateFormat': dateFormatFixture, field: 'cm:created'};
|
||||
component.settings = { 'dateFormat': dateFormatFixture, field: 'cm:created' };
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should display the required format when input date is invalid', () => {
|
||||
const inputEl = fixture.debugElement.query(By.css('input')).nativeElement;
|
||||
|
||||
@@ -194,7 +194,10 @@ describe('SearchDateRangeComponent', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(translationSpy.calls.mostRecent().args)
|
||||
.toEqual(['SEARCH.FILTER.VALIDATION.INVALID-DATE', {requiredFormat: dateFormatFixture}]);
|
||||
.toEqual(['SEARCH.FILTER.VALIDATION.INVALID-DATE', { requiredFormat: dateFormatFixture }]);
|
||||
|
||||
inputEl.value = '';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user