Skip to content

Commit

Permalink
Fixed panelmenu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrown-ScottLogic committed May 15, 2024
1 parent 9197738 commit 448fdd6
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/app/components/panelmenu/panelmenu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('PanelMenu', () => {
];
fixture.detectChanges();

const panelHeaderLinkEl = fixture.debugElement.query(By.css('.p-panelmenu-header-link'));
const panelHeaderLinkEl = fixture.debugElement.query(By.css('.p-panelmenu-header-action'));
expect(panelHeaderLinkEl.nativeElement.href).toContain('primeng');
expect(panelHeaderLinkEl.nativeElement.title).toEqual('primeng');
expect(panelHeaderLinkEl.nativeElement.target).toEqual('primeng');
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('PanelMenu', () => {
}
});

it('should change child url target icon disabled and title', () => {
it('should change child url target icon disabled and label', () => {
panelmenu.model = [
{
label: 'File',
Expand Down Expand Up @@ -212,9 +212,10 @@ describe('PanelMenu', () => {

const panelHeaderLinkEl = fixture.debugElement.query(By.css('.p-menuitem-link'));
expect(panelHeaderLinkEl.nativeElement.href).toContain('primeng');
expect(panelHeaderLinkEl.nativeElement.title).toEqual('primeng');
expect(panelHeaderLinkEl.nativeElement.target).toEqual('primeng');
expect(panelHeaderLinkEl.nativeElement.disabled).toBeTruthy;
expect(panelHeaderLinkEl.query(By.css('.p-menuitem-icon')).nativeElement.className).toContain('Primeng ROCKS!');
expect(panelHeaderLinkEl.nativeElement.innerHTML).toContain("New");
});

it('should show items and call toggle', () => {
Expand All @@ -241,12 +242,11 @@ describe('PanelMenu', () => {
headerLinks[0].nativeElement.click();
fixture.detectChanges();

const iconEl = fixture.debugElement.query(By.css('.p-panelmenu-icon'));
const firstSubMenuComponent = fixture.debugElement.query(By.css('.p-panelmenu-root-submenu')).componentInstance as PanelMenuSub;
const icon = fixture.debugElement.query(By.css('.p-icon'));
expect(handleClickSpy).toHaveBeenCalled();
expect(panelmenu.animating).toEqual(true);
expect(panelmenu.model[0].expanded).toEqual(true);
expect(iconEl.nativeElement.tagName.toLowerCase()).toContain('svg');
expect(icon.nativeElement.tagName.toLowerCase()).toContain('svg');
});

it('should select multiple', () => {
Expand All @@ -265,16 +265,14 @@ describe('PanelMenu', () => {
]
}
];
panelmenu.multiple = true;
fixture.detectChanges();

const headerLinks = fixture.debugElement.queryAll(By.css('.p-panelmenu-header-link'));
const headerLinks = fixture.debugElement.queryAll(By.css('.p-panelmenu-header-content'));
headerLinks[0].nativeElement.click();
headerLinks[1].nativeElement.click();
fixture.detectChanges();

const subMenuEls = fixture.debugElement.queryAll(By.css('.p-panelmenu-root-submenu'));
const firstSubMenuComponent = subMenuEls[0].componentInstance as PanelMenuSub;
const seconSubMenuComponent = subMenuEls[1].componentInstance as PanelMenuSub;
const activeEls = fixture.debugElement.queryAll(By.css('.p-highlight'));
expect(activeEls.length).toEqual(2);
let x = 0;
Expand All @@ -284,9 +282,6 @@ describe('PanelMenu', () => {
}
expect(panelmenu.model[0].expanded).toEqual(true);
expect(panelmenu.model[1].expanded).toEqual(true);
expect(subMenuEls.length).toEqual(2);
// expect(firstSubMenuComponent.expanded).toEqual(true);
// expect(seconSubMenuComponent.expanded).toEqual(true);
});

it('should not select multiple', () => {
Expand All @@ -308,7 +303,7 @@ describe('PanelMenu', () => {
panelmenu.multiple = false;
fixture.detectChanges();

const headerLinks = fixture.debugElement.queryAll(By.css('.p-panelmenu-header-link'));
const headerLinks = fixture.debugElement.queryAll(By.css('.p-panelmenu-header-content'));
headerLinks[0].nativeElement.click();
headerLinks[1].nativeElement.click();
fixture.detectChanges();
Expand Down

0 comments on commit 448fdd6

Please sign in to comment.