mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
@@ -86,12 +86,44 @@ describe('AlfrescoSearchControlComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.componentInstance.searchChange.subscribe(e => {
|
||||
expect(e.value).toBe('customSearchTerm211');
|
||||
expect(e.valid).toBe(true);
|
||||
done();
|
||||
});
|
||||
component.searchControl.setValue('customSearchTerm211', true);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should update FAYT search when user inputs a valid term', (done) => {
|
||||
fixture.componentInstance.searchChange.subscribe(() => {
|
||||
expect(fixture.componentInstance.liveSearchTerm).toBe('customSearchTerm');
|
||||
done();
|
||||
});
|
||||
fixture.detectChanges();
|
||||
fixture.componentInstance.searchTerm = 'customSearchTerm';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should NOT update FAYT term when user inputs a search term less than 3 characters', (done) => {
|
||||
fixture.componentInstance.searchChange.subscribe(() => {
|
||||
expect(fixture.componentInstance.liveSearchTerm).toBe('');
|
||||
done();
|
||||
});
|
||||
fixture.detectChanges();
|
||||
fixture.componentInstance.searchTerm = 'cu';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should still fire an event when user inputs a search term less than 3 characters', (done) => {
|
||||
fixture.componentInstance.searchChange.subscribe((e) => {
|
||||
expect(e.value).toBe('cu');
|
||||
expect(e.valid).toBe(false);
|
||||
done();
|
||||
});
|
||||
fixture.detectChanges();
|
||||
fixture.componentInstance.searchTerm = 'cu';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('Component rendering', () => {
|
||||
|
||||
it('should display a text input field by default', () => {
|
||||
|
@@ -111,9 +111,9 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private onSearchTermChange(value: string): void {
|
||||
this.liveSearchTerm = value;
|
||||
this.searchControl.setValue(value, true);
|
||||
this.searchValid = this.searchControl.valid;
|
||||
this.liveSearchTerm = this.searchValid ? value : '';
|
||||
this.searchControl.setValue(value, true);
|
||||
this.searchChange.emit({
|
||||
value: value,
|
||||
valid: this.searchValid
|
||||
|
Reference in New Issue
Block a user