Skip to content

Commit

Permalink
test(test): test
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorrea97 committed Oct 31, 2023
1 parent 5e2debb commit 9ece45d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*ngIf="clean && !disabled && inp.value"
class="po-combo-clean"
(click)="clear(); $event.preventDefault()"
(keydown.enter)="clear(); $event.preventDefault()"
(keydown.enter)="clearAndFocus(); $event.preventDefault()"
>
<span
[class.po-border-focused]="!disabled && comboOpen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,16 @@ describe('PoComboComponent:', () => {
expect(component.inputEl.nativeElement.focus).toHaveBeenCalled();
});

it('should call inputEl.nativeElement and clear', () => {
spyOn(component.inputEl.nativeElement, 'focus');
spyOn(component, 'clear');

component.clearAndFocus();

expect(component.inputEl.nativeElement.focus).toHaveBeenCalled();
expect(component.clear).toHaveBeenCalled();
});

it('onOptionClick: should call `stopPropagation` if has an event parameter', () => {
const option: PoComboOption = { value: 'value', label: 'label' };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ export class PoComboComponent extends PoComboBaseComponent implements AfterViewI
this.applyFilter('', true);
}

clearAndFocus() {
this.clear(null);
this.inputEl.nativeElement.focus();
}

private adjustContainerPosition() {
this.controlPosition.adjustPosition(poComboContainerPositionDefault);
}
Expand Down

0 comments on commit 9ece45d

Please sign in to comment.