Skip to content

Commit

Permalink
#25470 Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelrojas committed Jan 12, 2024
1 parent fcb2696 commit 2eabf7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class="searchable-dropdown__data-list-item"
[class.selected]="item[labelPropertyName] === valueString"
(click)="handleClick(item)"
data-testid="searchable-dropdown-data-list-item"
><i class="pi pi-check" *ngIf="item[labelPropertyName] === valueString"></i
>{{ item.label }}</span
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ describe('SearchableDropdownComponent', () => {
expect(hostComp.placeholder).toEqual(comp.valueString);
});

describe('star class', () => {
it('should add the star css class when item has default property set to true', () => {
describe('selected class', () => {
it('should add the selected css class when item has been clicked', () => {
hostComp.data = [
{
id: 1,
Expand All @@ -355,13 +355,14 @@ describe('SearchableDropdownComponent', () => {

hostFixture.detectChanges();

const item = de.query(
By.css('p-dataview .p-dataview-content .searchable-dropdown__data-list-item')
);
const item = de.query(By.css('[data-testid="searchable-dropdown-data-list-item"]'));

expect(item.classes['star']).toBeTruthy();
item.triggerEventHandler('click', null);
hostFixture.detectChanges();

expect(item.classes['selected']).toBeTruthy();
});
it('should not add css star class when item default property is set to false', () => {
it('should not add selected star class when is not clicked', () => {
hostComp.data = [
{
id: 1,
Expand All @@ -376,10 +377,7 @@ describe('SearchableDropdownComponent', () => {

hostFixture.detectChanges();

const item = de.query(
By.css('p-dataview .p-dataview-content .searchable-dropdown__data-list-item')
);

const item = de.query(By.css('[data-testid="searchable-dropdown-data-list-item"]'));
expect(item.classes['star']).toBeFalsy();
});
});
Expand Down

0 comments on commit 2eabf7e

Please sign in to comment.