Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unit test #15565

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/components/inputmask/inputmask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const INPUTMASK_VALUE_ACCESSOR: any = {
(keydown)="onInputKeydown($event)"
(keypress)="onKeyPress($event)"
pAutoFocus
[variant]="variant"
[attr.variant]="variant"
Copy link
Contributor

@cetincakiroglu cetincakiroglu May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variant is an input property of pInputText, I've accidentally accepted like that. Could you please add [variant] again and open a new PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

[autofocus]="autofocus"
(input)="onInputChange($event)"
(paste)="handleInputChange($event)"
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/inputnumber/inputnumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const INPUTNUMBER_VALUE_ACCESSOR: any = {
[ngStyle]="inputStyle"
[class]="inputStyleClass"
[value]="formattedValue()"
[variant]="variant"
[attr.variant]="variant"
[attr.aria-valuemin]="min"
[attr.aria-valuemax]="max"
[attr.aria-valuenow]="value"
Expand Down
33 changes: 14 additions & 19 deletions src/app/components/listbox/listbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Listbox', () => {
{ label: 'VW', value: 'VW' },
{ label: 'Volvo', value: 'Volvo' }
];
const onOptionSelectSpy = spyOn(listbox, 'onOptionSelect').and.callThrough();
const onClickSpy = spyOn(listbox.onClick, 'emit').and.callThrough();
fixture.detectChanges();

const bmwEl = fixture.debugElement.query(By.css('ul')).children[1].nativeElement;
Expand All @@ -52,7 +52,7 @@ describe('Listbox', () => {

const filterInputEl = fixture.debugElement.query(By.css('.p-listbox-filter-container')).query(By.css('input')).nativeElement;
expect(filterInputEl.disabled).toEqual(true);
expect(onOptionSelectSpy).not.toHaveBeenCalled();
expect(onClickSpy).not.toHaveBeenCalled();
});

it('should call onOptionTouchEnd', () => {
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('Listbox', () => {
fixture.detectChanges();

expect(onOptionTouchEndSpy).toHaveBeenCalled();
expect(listbox.optionTouched).toEqual(undefined);
expect(listbox.optionTouched).toBeTrue();
});

it('should change style and styleClass', () => {
Expand Down Expand Up @@ -259,7 +259,6 @@ describe('Listbox', () => {
fixture.detectChanges();

expect(listbox.value.length).toEqual(10);
expect(listbox.selectAll).toEqual(true);
expect(selectAllEl.className).toContain('p-highlight');
expect(onToggleAllSpy).toHaveBeenCalled();
});
Expand All @@ -278,6 +277,7 @@ describe('Listbox', () => {
{ label: 'Volvo', value: 'Volvo' }
];
listbox.filter = true;
listbox.optionLabel = 'label';
fixture.detectChanges();

const filterInputEl = fixture.debugElement.query(By.css('.p-listbox-filter-container')).children[0].nativeElement;
Expand Down Expand Up @@ -503,7 +503,6 @@ describe('Listbox', () => {
fixture.detectChanges();

expect(listbox.value.length).toEqual(0);
expect(listbox.selectAll).toEqual(false);
expect(selectAllEl.className).not.toContain('p-highlight');
expect(toggleAllSpy).toHaveBeenCalledTimes(2);
});
Expand Down Expand Up @@ -577,6 +576,7 @@ describe('Listbox', () => {
listbox.checkbox = true;
listbox.filter = true;
listbox.filterValue = 'o';
listbox.optionLabel = 'label';
fixture.detectChanges();

const headerCheckBoxReadonlyEl = fixture.debugElement.query(By.css('.p-checkbox.p-component')).query(By.css('input'));
Expand Down Expand Up @@ -609,27 +609,22 @@ describe('Listbox', () => {
{ label: 'VW', value: 'VW' },
{ label: 'Volvo', value: 'Volvo' }
];
const findNextOptionIndexSpy = spyOn(listbox, 'findNextOptionIndex').and.callThrough();
const findPrevOptionIndexSpy = spyOn(listbox, 'findPrevOptionIndex').and.callThrough();
const onArrowDownKeySpy = spyOn(listbox, 'onArrowDownKey').and.callThrough();
const onArrowUpKeySpy = spyOn(listbox, 'onArrowUpKey').and.callThrough();
fixture.detectChanges();

const bmwEl = fixture.debugElement.query(By.css('ul')).children[1].nativeElement;
const event: any = document.createEvent('CustomEvent');
event.which = 40;
event.initEvent('keydown');
bmwEl.dispatchEvent(event);
const bmwEl = fixture.debugElement.query(By.css('.p-listbox-list')).nativeElement;
bmwEl.dispatchEvent(new KeyboardEvent('keydown', { code: 'ArrowDown' }));
fixture.detectChanges();

event.which = 38;
bmwEl.dispatchEvent(event);
bmwEl.dispatchEvent(new KeyboardEvent('keydown', { code: 'ArrowUp' }));
fixture.detectChanges();

event.which = 13;
bmwEl.dispatchEvent(event);
bmwEl.dispatchEvent(new KeyboardEvent('keydown', { code: 'Enter' }));
fixture.detectChanges();

expect(findNextOptionIndexSpy).toHaveBeenCalled();
expect(findPrevOptionIndexSpy).toHaveBeenCalled();
expect(listbox.value).toEqual('BMW');
expect(onArrowDownKeySpy).toHaveBeenCalled();
expect(onArrowUpKeySpy).toHaveBeenCalled();
expect(listbox.value).toEqual('Audi');
});
});
2 changes: 1 addition & 1 deletion src/app/components/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const LISTBOX_VALUE_ACCESSOR: any = {
[attr.aria-selected]="isSelected(option)"
[attr.aria-disabled]="isOptionDisabled(option)"
[attr.aria-setsize]="ariaSetSize"
[ariaPosInset]="getAriaPosInset(getOptionIndex(i, scrollerOptions))"
[attr.ariaPosInset]="getAriaPosInset(getOptionIndex(i, scrollerOptions))"
(click)="onOptionSelect($event, option, getOptionIndex(i, scrollerOptions))"
(dblclick)="onOptionDoubleClick($event, option)"
(mousedown)="onOptionMouseDown($event, getOptionIndex(i, scrollerOptions))"
Expand Down
Loading